A hundred servers running backups at the same hour is a recipe for overload. This episode teaches randomization with sleep $((RANDOM % 300)), choosing quiet hours of 02.00-04.00, and strategies to spread the load so mass schedules don't cripple your infrastructure.

In episode 10 we scheduled backups. Now consider a bigger scenario: you manage a hundred servers, and all of them run a backup at 0 2 * * *. At 02.00, a hundred simultaneous backup processes hit the destination server — bandwidth is drained, storage is overloaded, and a "correct" schedule ends up creating a new problem.
This is the peak load problem you must think about from the start. The cause isn't a wrong schedule — it's the natural synchronization when everyone picks a "reasonable" hour. This episode covers how to spread the load.
The simplest and highly effective trick: let the job wait for a random amount of time before starting its work.
30 2 * * * sleep $((RANDOM % 300)) && /usr/local/bin/backup.sh$((RANDOM % 300)) produces a random number from 0-299.With a hundred servers, that 5-minute window spreads a hundred backups across a wider time range — the load peak becomes much gentler.
Tip
The size of the random window (% 300) should scale with the number of hosts and job duration. The more hosts and the longer the job, the wider the window. For 500 hosts, % 1800 (30 minutes) makes more sense than 5 minutes.
Pure randomness is unpredictable — sometimes good, sometimes awkward for auditing. A deterministic alternative: derive the delay from a hash of the hostname.
30 2 * * * sleep $((0x$(hostname | md5sum | cut -c1-4) % 300)) && /usr/local/bin/backup.shEach host's delay is constant across executions (easy to audit) but different between hosts (load is spread).
For cron.daily jobs managed by anacron, use RANDOM_DELAY (from episode 8):
RANDOM_DELAY=45Anacron delays each job by a random amount of up to 45 minutes after the machine becomes active, spreading the boot load.
Heavy backup needs ideally run during quiet hours — typically 02.00-04.00 local time, when user traffic is minimal and resource contention is low.
15 2 * * * /usr/local/bin/backup.shImagine 100 hosts running 0 2 * * * rsync ... nas:/backup. Without mitigation:
With random delay, the load curve changes from a sharp spike to a gentle slope — all jobs finish across a longer window, and none fail due to resource contention.
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin
30 2 * * * sleep $((RANDOM % 300)) && flock -n /var/lock/backup.lock timeout 50m /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1The combination: random delay (spread load) + flock (anti-overlap) + timeout (anti-hang) + log (trace).
Warning
Randomization and locking must work together. Without flock, two jobs that happen to draw nearly identical delays will still run concurrently. Without randomization, flock instead makes many hosts wait on each other in the same minute — a queue that's just as bad.
| Strategy | Strengths | Weaknesses | Best for |
|---|---|---|---|
sleep $((RANDOM % N)) | Simple, spreads naturally | Not deterministic | All scales |
| Hostname hash | Deterministic, easy audit | Needs updating when new hosts appear | Stable infra |
anacron RANDOM_DELAY | Free for cron.daily | Limited window | anacron jobs |
| Manual quiet hours | No overhead | Needs analysis | Light jobs |
Key takeaways:
sleep $((RANDOM % 300)) spreads load simply and effectively.In episode 12 we'll cover notifications and alerting — MAILTO, sending messages to Slack/Telegram via curl, Zabbix/Prometheus monitoring integration, and an on-failure alert pattern that only bothers you when something is genuinely wrong!