Cron vs systemd timers

On this page

Use cron when you want one line and a portable file; use a systemd timer when you want logs in the journal, catch-up after downtime, resource limits and dependencies. Both can be monitored the same way: with a ping from the job.

How do they compare?

Questioncronsystemd timer
Where is the schedule?One crontab lineA .timer unit and a .service unit
Schedule syntaxFive fields; names for months and daysOnCalendar expressions with seconds, or monotonic timers
Missed run while the machine was offSkippedCaught up with Persistent=true on OnCalendar timers
AccuracyTo the minuteWithin AccuracySec, one minute by default
Random spread of start timesNot built inRandomizedDelaySec
Output and logsMail or your own redirectThe journal, per unit
Failure stateNone keptThe unit shows failed with its exit status
EnvironmentMinimal: SHELL, LOGNAME, HOMEClean; set Environment= or EnvironmentFile=

When does each win?

  • Cron: quick jobs on any Unix machine, portable crontabs, hosts where you do not control systemd.
  • systemd timers: jobs that must catch up after downtime, services that need sandboxing or limits, and anywhere you want systemctl status to tell you the last result.

How do I monitor each?

For cron, append a curl to the line, as in the crontab guide. For a timer, use ExecStartPre and ExecStopPost in the service so that the start and the exit status are reported, as in the systemd guide. A cron check can follow either one, because the check cares about when pings arrive, not about the scheduler behind them.

Sources

Questions and answers

Can I convert a crontab line to OnCalendar?
Mostly. The dialect converter writes the OnCalendar form of a cron schedule and flags anything that does not translate.
Does a timer replace the need for monitoring?
It improves the evidence after the fact. It does not tell you when a timer is disabled, the machine is off, or the unit was never started. A heartbeat does.
Know the moment a job goes quiet

Create a check, add one curl to the job, and CronMissed alerts you when a ping is late or reports a failure.

Start monitoring