Cron versus systemd timers
| cron | systemd timer | |
|---|---|---|
| Definition | One line in a crontab | Two files: .timer (when) and .service (what) |
| Missed runs | Lost (unless anacron) | Persistent=true runs them at next boot |
| Environment | Minimal PATH, no profile; output mailed | Defined in the unit; output to the journal |
| Overlap | Runs again even if the last run is still going | Never overlaps: a timer waits for its service to finish |
| Dependencies | None | After=network-online.target, mounts, other units |
| Resource limits, sandboxing | No | All of systemd's: MemoryMax, CPUQuota, ProtectSystem… |
| Inspection | crontab -l, grep the syslog | systemctl list-timers, journalctl -u, systemctl status |
| Simplicity | One line | Twenty lines |
For a one-liner on a personal machine, cron is fine. For anything on a server that must not overlap, must catch up after downtime, needs limits, or whose logs someone will read later, a timer is the better tool, and the converter writes the boilerplate.
What the converter does with the command
ExecStart= takes an absolute path and arguments, not a shell line. Redirections (>> log 2>&1) are dropped because the journal captures output; pipes and && are wrapped in /bin/sh -c '…'. Cron's %-means-newline rule does not apply, so date +%F works as written. Environment variables set in the crontab go into Environment= lines.
Day-of-month and day-of-week
If a cron line restricts both, cron fires when either matches; systemd requires both. The converter warns, since that schedule needs two timers to reproduce.
Questions
Where do the files go?
/etc/systemd/system/ for system units, ~/.config/systemd/user/ for user units (then use systemctl --user and loginctl enable-linger). Run systemctl daemon-reload after adding or editing.
How do I see when it will next run?
systemctl list-timers --all shows the next and last run of every timer. systemd-analyze calendar "expr" shows the next elapse for any OnCalendar expression.
How do I run it now, without waiting?
systemctl start name.service (not the timer). The timer keeps its own schedule.
Can a timer run every 10 seconds?
Yes, with OnCalendar=*:*:0/10 and AccuracySec=1s, or with OnUnitActiveSec=10s for “10 seconds after the last run finished”. Cron cannot go below one minute.