Site icon New Generation Enterprise Linux

Stop crontab from running your jobs when you are not looking

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

Stop crontab from running your jobs when you are not looking

🧩 The Challenge

Dealing with a production server where a cron job kept firing off right in the middle of a database backup is a nightmare. You end up with a locked table and a support ticket that ruins your entire evening.

💡 The Fix

Use systemd timers instead of the old-school crontab. They actually let you define dependencies so your backup script knows to wait until the other processes are finished.

systemctl edit --full my-backup.timer
[Timer]
OnCalendar=*-*-* 03:00:00
AccuracySec=1m
Persistent=true

systemctl enable --now my-backup.timer

⚙️ Why It Works

Moving to systemd allows you to hook tasks into the wider service management graph. You gain the ability to chain jobs with After= and Before= directives, which turns your blind cron execution into an actual coordinated workflow.

🚀 Pro-Tip: Run systemd-analyze calendar ‘*-*-* 03:00:00’ to double-check that your timer is going to fire when you actually think it will.

Linux Tips & Tricks | © ngelinux.com | 7/26/2026

0 0 votes
Article Rating
Exit mobile version