Alvin's Notebook

Three reasons I moved from cron to systemd timers

2025-03-12 · linuxops

After a pile of cron jobs accumulated across servers, the management cost crept up. Earlier this year I migrated scheduled jobs on three machines to systemd timers. Three reasons were decisive.

First, logging. Cron output goes to mail nobody reads, or to log files you redirect yourself. Timer units land in the journal automatically: one command shows the full trigger history for any unit.

Second, dependencies. A backup job that needs a mount to be alive was guarded with sleeps and lock files; under systemd it is an After= and Requires= line, stated once and enforced.

Third, missed runs. Cron jobs skipped during downtime stay skipped. OnCalendar= with Persistent=true catches up once the machine is back, which matters enormously for backup jobs.

# /etc/systemd/system/backup.timer
[Timer]
OnCalendar=*-*-* 03:30:00
Persistent=true

[Install]
WantedBy=timers.target

Migration cost was lower than expected: one .service plus one .timer each. The one gotcha worth remembering: enable the timer, not just the service, or nothing will ever fire.