Systemd timers

little guide to use systemd timers


Here's something I didn't know..

I was experiencing some issues with a service on a box;

specifically, the service was in a failed status every time I rebooted the machine, but when restarted everything was fine.

Clearly the service needed a delay somehow but I didn't know how to achieve this with systemd.

Turns out that I just needed to create a "myservice".timer file into the same folder containing my original service file "myservice.service"

[Unit]
Description=Run myservice after a little delay

[Timer]
OnBootSec=1min

[Install]
WantedBy=timers.target

and then, daemon-reload, disable the service and enable the timer:

~# systemctl daemon-reload
~# systemctl disable myservice.service
~# systemctl enable myservice.timer

and voilĂ .

Creative Commons Licence
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License .