Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Automation & toolingMixed 22 series

Cron to systemd timer: the migration path

Cron is not broken. It is just quiet: no log, no status, no record of the run that never happened.

Quick reference

Six steps from a crontab line to a unit you can inspect.

  1. Inventory — crontab -l for every user, and every file in /etc/cron.d.
  2. Service unit — Same command, absolute paths, secrets from EnvironmentFile.
  3. Timer unit — OnCalendar, Persistent=true, a randomised delay.
  4. Verify — systemd-analyze calendar, a manual start, then the journal.
  5. Cut over — Disable the cron line, enable the timer, watch two runs.
  6. 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?

More notes: Automation & tooling

Open in the notes app: search, filters, copy This note on GitHub