Interview Prep/Linux/Scheduling, automation and scripting

You have 300 servers running the same cron job at midnight, and they hammer a shared API. How do you fix it?

IntermediateScenarioScheduling, automation and scripting
Answer

Situation read → Thundering herd; spread the start times.

What I'd do →

  1. With systemd timers: RandomizedDelaySec=1800 (and FixedRandomDelay=true for a stable per-host offset).
  2. With cron, add a random sleep: 0 0 * * * sleep $((RANDOM % 1800)); /usr/local/bin/job.sh (needs SHELL=/bin/bash).
  3. Or derive the minute from the hostname in your config management (Ansible random filter with seed=inventory_hostname).

Why → Jitter turns a spike into a flat load.

Interview tip → Mention that $RANDOM is a bash feature and cron's default shell is /bin/sh.

All Linux questions Roadmap: Linux

More on Scheduling, automation and scripting