TOOL » LINUX » SYSTEMCTL

Timer

Usage

There are user and system timers. If dealing with system timers, root privileges are needed.

shell
systemctl OPTION ACTION mytimer.timer

Check the timers status with:

shell
systemctl --user list-timers --all
OptionDescription
--userUse the user service manager.
ActionDescription
startStart the service.
stopStop the service.
restartRestart the service.
enableEnable automatic service startup on boot.
disableDisable automatic service startup on boot.
list-timersList available timers and its status.

Creation

After any changes to a timer, run:

shell
systemctl --user daemon-reload
ScopePath
System/etc/systemd/system
User~/.config/systemd/user

Example of mytimer.timer:

ini
[Unit]
Description=mytimer

[Timer]
OnCalendar=Sat *-*-* 18:00:00
Persistent=true

[Install]
WantedBy=timers.target
SettingDescription
OnStartupSecActivate the timer relative to boot time.
OnUnitActiveSecActivate the timer relative to last activation time.
OnCalendarDefines realtime (cron-like) timers.