mercredi 17 août 2016

Crontab - run command random time

I have created a cron job in which it runs a command within random value (Example 10 mins) at 11pm everyday. I found this example online but I can not find reference.

What I have that doesn't work

SHELL=/bin/bash
PATH=/usr/bin:$PATH
LOCAL_CONFIG_DIR=/user/folder
    0  11  *   *   * sleep $(($RANDOM \% 10))m && python /user/folder/file.py

The following works but does not run at random 10 mins:

SHELL=/bin/bash
PATH=/usr/bin:$PATH
LOCAL_CONFIG_DIR=/user/folder

0  11  *   *   * python /user/folder/file.py 

Wonder if my issue is with $Random?




Aucun commentaire:

Enregistrer un commentaire