Stop letting your background tasks run at midnight by default

Cron & Task Scheduling (Cron/Systemd Timers/At)

Stop letting your background tasks run at midnight by default

🧩 The Challenge

Everyone dumps their heavy cleanup scripts into cron and assumes the server can handle the load at 3:00 AM, but then the backup process kicks in and the whole box grinds to a halt. I’ve wasted so many early mornings troubleshooting why production services were timing out during these collision events.

💡 The Fix

Move those resource-heavy maintenance tasks over to systemd timers with randomized delays and steady load management. It stops the thundering herd effect before it starts.

systemctl edit --full my-cleanup.timer
[Timer]
OnCalendar=daily
RandomizedDelaySec=3600
AccuracySec=10min

⚙️ Why It Works

Setting a randomized delay tells systemd to pick a window to run the job, spreading out the load so you aren’t slamming your disk I/O all at once. By bumping the accuracy down, you’re also telling the kernel it doesn’t need to wake up the CPU exactly on the dot, which saves cycles on virtualized hosts.

🚀 Pro-Tip: Use systemd-analyze calendar to check your syntax before you commit; it’ll save you from the dreaded “why didn’t this run?” headache.

Linux Tips & Tricks | © ngelinux.com | 9/11/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted