Running a Transient Timer Unit
Transient timers are temporary timers that are valid only for the current session. These
timers can be created to run a program or script directly without requiring service or
timer units to be configured within systemd. These units are generated
by using the systemd-run command. See the
systemd-run(1) manual page for more information.
The parameter options that you would add to the
unit-file.timer file also serve as arguments
when you use systemd-run command to run a transient timer unit.
The following examples show how to use systemd-run to activate transient
timers.
-
Run
update.serviceafter 2 hours have elapsed.sudo systemd-run --on-active="2h" --unit update.service -
Create
~/tmp/myfileafter 1 hour.sudo systemd-run --on-active="1h" /bin/touch ~/tmp/myfile -
Run
~/myscripts/update.sh5 minutes after the service manager is started. Use this syntax to run a service after the service manager has started at user login.sudo systemd-run --on-startup="5m" ~/myscripts/update.sh -
Run
myjob.service10 minutes after system boot.sudo systemd-run --on-boot="10m" --unit myjob.service -
Run
report.serviceat the end of the day.sudo systemd-run --on-calendar="17:00:00"