Pcornel
Linux · systemd & Services

Timers

Cheat sheet · https://pcornel.dk/topic.php?topic=2726

Back to the Topic

Answer

A systemd timer (.timer) starts a matching .service on a schedule (OnCalendar=) or after an interval (OnBootSec=, OnUnitActiveSec=). It replaces many cron jobs with logging and dependency support.

Remember

Enable the .timer, not the .service. Persistent=true runs missed jobs after downtime. Test the schedule with systemd-analyze calendar '<expr>'. Output goes to the journal of the .service.

First checks

  • systemctl list-timers --all — timers with next and last run
  • systemctl status <unit> — state, main PID, recent log lines
  • systemctl list-units --failed — failed units
  • journalctl -u <unit> -b — the unit's log since boot
  • systemctl cat <unit> — unit file plus drop-ins
  • systemd-analyze verify <unit> — unit file errors

Verify in this order

timer active → schedule reached → matching service started → job runs → result in the journal

Where it usually breaks

First mismatch in persistent unit/config/generator → dependency/order graph → systemd state → process/cgroup → socket/resource dependency → journal → consumer check; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2726

Confirmation

Confirm action

Continue?