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
- 1List active timers: systemctl list-timers --all
- 2Create timer: /etc/systemd/system/mytask.timer with [Timer] section containing OnCalendar=
- 3Create service: /etc/systemd/system/mytask.service with [Service] section containing ExecStart=
- 4Validate calendar expression: systemd-analyze calendar 'Mon..Fri *-*-* 09:00:00'
- 5Enable and start: systemctl daemon-reload && systemctl enable --now mytask.timer
- 6Check logs: journalctl -u mytask.service to see output from the timer-triggered service
Tags
systemd-timercron-replacementschedulingtimerautomation
Related Items
More in Systemd
linux-systemd-service-failedLinux systemd Service Failed to Start — Unit Entered Failed State
Errorlinux-systemd-dependency-failedLinux systemd Dependency Failed — Service Cannot Start
Errorlinux-systemd-journal-errorsLinux systemd Journal Errors — Failed Services, Dependencies & Timers
Warninglinux-systemctl-service-errorsSystemctl Service Errors — Failed to Start, Dependency, and Unit File Issues
Errorlinux-journalctl-usage-guideJournalctl Usage Guide — Reading System Logs and Debugging Services
InformationalFrequently 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.