Linux 101 : Systemd timers - the "cron" of systemd -
To view the list of timers on a systemd system, we use the below command:
To have more information about the systemd timers, we use the below command:
- NEXT : next time the timer is scheduled.
- LEFT : the time is left before the timer runs.
- LAST : the last time the timer ran.
- PASSED : the amount of time since the last "run" of the timer.
- UNIT : the name of the unit configuration file for the timer.
- ACTIVATES : the service that the timer runs.
We could view information about the - apt-daily-upgrade.service - timer for example using the below command:
The monotonic timer:
The monotonic method configures a job to be triggered after a certain event.
This above timer activates the "service_1.service".
- OnBootSec : tells the service to run 10 minutes after the system starts.
- OnUnitInactiveSec : tells the timer to run the "service_1.service" one hour after its last "run".
- Unit : this field is optional since the timer runs a service that has the same name as the timer. We use it when we give the service a different name from the timer.
The real-time timer is used to run a job on a given date and time.
For example, we could have:
- OnCalendar : Sets the job to run at a set interval, for example weekly means every "Monday".
- AccuracySec: set a delay or an interval during which a job could run.
- Persistent=true : for example makes the job persistent, the job will be run at boot time if the machine happens to be down when the job is scheduled.
Examples of real-time timers:
To run a job on the third of April, we use the below parameter:
- OnCalendar=2021-04-05 00:00:00
- OnCalendar=*-*-06,15,20 17:00:00
Comments