Error Codes Wiki

Systemd Timer Errors — Replacing Cron with Systemd Timers and Troubleshooting

Warningsystemd

Overview

Fix systemd timer errors including timers not triggering, incorrect scheduling, and transitioning from cron to systemd timers for better logging and control.

Key Details

  • Systemd timers are the modern replacement for cron, offering better logging via journalctl
  • Each timer requires two unit files: a .timer file and a corresponding .service file
  • Timer types: OnCalendar (calendar-based) and OnBootSec/OnUnitActiveSec (relative to events)
  • Timers are managed with systemctl: enable, start, status, list-timers
  • AccuracySec and RandomizedDelaySec prevent all timers from firing at the exact same time

Common Causes

  • Timer not enabled: created but not started with systemctl enable --now
  • Corresponding .service file missing or misconfigured
  • OnCalendar expression syntax incorrect (use systemd-analyze calendar to validate)
  • Timer enabled but service unit fails silently — not checked via journalctl
  • AccuracySec too large causing timer to fire minutes after the intended time

Steps

  1. 1List active timers: systemctl list-timers --all
  2. 2Create timer: /etc/systemd/system/mytask.timer with [Timer] section containing OnCalendar=
  3. 3Create service: /etc/systemd/system/mytask.service with [Service] section containing ExecStart=
  4. 4Validate calendar expression: systemd-analyze calendar 'Mon..Fri *-*-* 09:00:00'
  5. 5Enable and start: systemctl daemon-reload && systemctl enable --now mytask.timer
  6. 6Check logs: journalctl -u mytask.service to see output from the timer-triggered service

Tags

systemd-timercron-replacementschedulingtimerautomation

Related Items

More in Systemd

Frequently Asked Questions

Systemd timers for new tasks: they have better logging (journalctl), dependency management, and resource control. Cron is simpler for quick one-off schedules. Most modern distros support both.