Quick reference
Six steps from a crontab line to a unit you can inspect.
- Inventory — crontab -l for every user, and every file in /etc/cron.d.
- Service unit — Same command, absolute paths, secrets from EnvironmentFile.
- Timer unit — OnCalendar, Persistent=true, a randomised delay.
- Verify — systemd-analyze calendar, a manual start, then the journal.
- Cut over — Disable the cron line, enable the timer, watch two runs.
- Clean up — Delete the crontab entry, keep the units in git.
In one line: The crontab hides. A timer explains. The journal and Persistent are the difference.
Convert one job:
systemd-analyze calendar "*-*-* 03:00:00"Explained
Inventory. Run crontab -l as every user, then read /etc/cron.d and /etc/crontab. Most estates have the same job in two places, and one of them has been failing since a password changed.
Service unit. The command moves into a .service file with absolute paths. Environment goes in EnvironmentFile, secrets come from the credential store, and StandardOutput=journal replaces the mail that nobody reads.
Timer unit. OnCalendar replaces the five fields, Persistent=true catches up after downtime, and RandomizedDelaySec spreads the load. systemd-analyze calendar prints the next elapse, which is the first test.
Verify. Start the service by hand, read journalctl -u, then enable the timer and watch two scheduled runs before you trust it.
Cut over. Comment out the cron line, do not delete it, and keep both for a week. One owner, one run, one diff.
Clean up. Remove the entry, commit the units, and add the timer to the runbook.
The honest caveat: a timer is not more reliable than cron by itself. Without Persistent and an alert on failure, it fails just as quietly.
The lesson: migrate the job that has an owner, not the one nobody remembers.
Your turn: Which cron job would you convert first?
Related on this site
More notes: Automation & tooling
Open in the notes app: search, filters, copy This note on GitHub