Configuring a Monotonic Timer Unit
Monotonic timers that activate after a time span relative to a varying starting point, such as a boot event, or when a particular systemd
unit becomes active. These timer units stop if the computer is temporarily suspended or shut down. Monotonic timers are configured by using the OnTypeSec
option, where Type is the name of the event to which the timer is related. Common monotonic timers include OnBootSec
and OnUnitActiveSec
.
-
If needed, create a
.service
file that defines the service to be triggered by the timer unit. In the following procedure, the sample service is/etc/systemd/system/update.service
which is a service unit that runs an update script.For more information about creating service units, see Creating a User-Based systemd Service.
-
Decide the time and frequency for running the service. In this procedure, the timer is configured to run the service 10 minutes after a system boot, and every 2 hours from when the service is last activated.
This task shows you how to create a system timer to trigger a service to run at specific events, which are when the system boots or after 2 hours have lapsed from the timer's activation.