Hasty Briefsbeta

Bilingual

You Don't Love Systemd Timers Enough

6 hours ago
  • #systemd
  • #cron
  • #timers
  • The term 'cron job' is a metonym for scheduled tasks, even if not literally executed by cron daemons.
  • systemd timers are recommended over traditional cron for scheduled tasks due to modern features and better reliability.
  • Cron has issues like ambiguous PATH settings, lost stdout/stderr output, and difficult execution history tracking.
  • systemd timers solve cron problems and offer clearer scheduling, easier management, and better integration.
  • Creating a systemd timer involves defining a .service unit (the task) and a .timer unit (the schedule).
  • Timer schedules can be calendar-based (e.g., daily at 10:00) or relative to events (e.g., after boot).
  • The systemd-analyze calendar command helps validate and explain time expressions.
  • systemctl list-timers provides a comprehensive overview of all active timers on a system.
  • Timer options like WakeSystem= can resume a suspended system to run tasks, and Persistent= handles missed activations.
  • RandomizedOffsetSec= and FixedRandomDelay= help prevent thundering herd problems by spreading out execution times.