Adding a Random Delay to a Cron Job
To stop many machines hitting a server at the same second, add a random sleep before the job. RANDOM % 300 spreads it over five minutes.
The crontab line
0 * * * * sleep $((RANDOM % 300)); /path/job.sh
Bash's $RANDOM gives 0–300 seconds of jitter before each run. Ensure the line runs under bash.
RANDOM_DELAY in the crontab
Vixie/cronie supports a RANDOM_DELAY=15 line (minutes) that applies random jitter to all following jobs.
Why stagger jobs
Identical schedules across a fleet cause a thundering herd — a spike of simultaneous requests. Jitter smooths the load on shared backends.
FAQ
How do I add a random delay to a cron job?
Prefix it with a random sleep: sleep $((RANDOM % 300)) adds up to 5 minutes of jitter. Run it under bash.
What is RANDOM_DELAY in cron?
A cronie/Vixie setting (in minutes) placed in the crontab that applies a random delay to all jobs below it.
Why would I delay a cron job randomly?
To avoid a thundering herd — many hosts running the same schedule and hitting a shared server at the same instant.