Stop cron from nuking your server when a job goes rogue
Cron & Task Scheduling (Cron/Systemd Timers/At)
Stop cron from nuking your server when a job goes rogue
🧩 The Challenge
Everyone thinks a basic script is safe until a database backup hangs indefinitely and five copies of it eventually eat all your RAM. I’ve spent more than one Saturday rebooting production boxes because of this exact disaster.
💡 The Fix
Use the timeout utility to wrap your cron jobs so they automatically die if they overstay their welcome. It’s the easiest insurance policy you can get for your scripts.
* * * * * /usr/bin/timeout 300 /usr/local/bin/heavy-backup.sh
⚙️ Why It Works
Adding this wrapper tells the shell to send a SIGTERM to the process after the specified duration, ensuring a stalled task doesn’t turn into a permanent zombie that crashes your system.
🚀 Pro-Tip: Use timeout -k 10 to send a follow-up SIGKILL if the process is too stubborn to die gracefully on its own.
Linux Tips & Tricks | © ngelinux.com | 11/14/2026
