Systemd user timers
2018-02-22This is just a short post with some pointers on how to use Systemd timers, and specifically Systemd timers as user.
Useful command: Reload deamon after fiddling with .service or .timer file:
systemctl --user daemon-reload
List timers:
systemctl --user list-timers
If it doesn’t show up, check the status of the timer
systemctl --user status unit.timer
Service and timer files: A regular .service file is needed. And also a .timer file. This is a nice split and makes it easier to debug. Both should be places in:
~/.config/systemd/user unit.service:
[Unit]
Description=USER UNIT
[Service]
WorkingDirectory=/example/dir
ExecStart=/example/dir/exe
[Install]
WantedBy=default.target
unit.timer
[Unit]
Description=UNIT USER TIMER
[Timer]
OnCalendar=*-*-* 07:30:00
OnCalendar=*-*-* 19:00:00
Unit=unit.service
[Install]
WantedBy=timers.target
Multiple OnCalendar can be specified.
start and enable the timer!!
systemctl --user enable unit.timer
systemctl --user start unit.timer
Use list-timers to verify that all is Ok.
journalctl --user -f -u unit.service
is useful as well.