Posts List

Crontab with a random sleep

Tweet Recently ran into this problem. We had a crontab entry that looked something like this 0 0 * * * /usr/bin/sleep $((RANDOM\%90)); cmdHere What that attempted was to run a command a random amount of seconds once midnight hit. Now running the command on console causes it to error out $ /usr/bin/sleep $((RANDOM\%90)) -bash: RANDOM\%90: syntax error: invalid arithmetic operator (error token is "\%90") So what you might be saying is well the \ is messing it up so remove it.