Pcornel
Linux · Scheduling

systemd Timers

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

Back to the Topic

Answer

systemd timers schedule a .service with OnCalendar= (calendar times) or monotonic delays (OnBootSec=, OnUnitActiveSec=). They log to the journal and can catch up missed runs with Persistent=true.

Remember

Create a .service and a .timer with the same name, enable the timer. Add RandomizedDelaySec= to avoid many hosts running at once. Check expressions with systemd-analyze calendar.

First checks

  • systemd-analyze calendar '<expr>' — normalised schedule and next time
  • systemctl list-timers --all — systemd timers and next run
  • crontab -l -u <user> — a user's cron jobs
  • ls /etc/cron.d /etc/cron.daily — system cron jobs
  • journalctl -u cron -u crond --since today — cron executions

Commands

systemctl enable --now job.timer

Verify in this order

timer active → OnCalendar reached (or missed run with Persistent) → service started → result logged

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=2828

Confirmation

Confirm action

Continue?