Site icon New Generation Enterprise Linux

Ditch Cron for Systemd Timers and stop guessing when things run

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

Ditch Cron for Systemd Timers and stop guessing when things run

đź§© The Challenge

Dealing with a dozen disparate cron jobs spread across different servers is a nightmare when you’re trying to debug why a database backup didn’t trigger at 3 AM. Half the time the environment path is missing, and the other half you’re just praying the job didn’t overlap with the last one.

đź’ˇ The Fix

Move those aging scripts into systemd timers to get proper logging, dependency management, and a unified way to check if your tasks actually succeeded or crashed hard. It turns a mystery box into a first-class service citizen.

systemctl edit --full my-backup.service
systemctl edit --full my-backup.timer
systemctl enable --now my-backup.timer

⚙️ Why It Works

By splitting the task into a service and a timer, you decouple the “what” from the “when,” letting systemd handle the execution environment exactly like it does for your web servers or databases. You can finally see the logs for the specific run using journalctl rather than digging through /var/mail/root.

🚀 Pro-Tip: Use the OnUnitActiveSec= directive to ensure a job waits a specific amount of time after the previous run finishes, preventing those dreaded resource-killing overlaps.

Linux Tips & Tricks | © ngelinux.com | 10/24/2026

0 0 votes
Article Rating
Exit mobile version