Define a Scheduled Task

Learn how to create and manage systemd timers to schedule tasks on Linux systems. You'll work with timer units, service units, and systemd configuration to set up automated task execution at specific intervals.

What you'll learn:

  • Creating directories and executable scripts
  • Writing systemd service unit files
  • Configuring systemd timer units with OnCalendar expressions
  • Managing timer lifecycle (enable, start, stop)
  • Monitoring active timers

About Systemd Timers

Systemd timers provide a modern alternative to cron for scheduling tasks. They offer better integration with the systemd ecosystem, improved logging, and more flexible scheduling options. Timer units work in conjunction with service units to provide robust task scheduling capabilities.

💡 Quick Tips:

  • Timer units have the .timer extension
  • Service units have the .service extension
  • OnCalendar expressions define when timers trigger
  • Use systemctl list-timers to monitor active timers
  • Always run daemon-reload after creating new unit files