Delaying the start of a systemd unit at boot

I’m keeping an eye on what’s going on with my servers via remote Gkrellm system monitors.

I noticed that on one server the hardware sensors seemed to need a bit more time than normal to initialize on boot, so the gkrellmd daemon occasionally missed some sensor information, requiring a manual restart of gkrellmd.service after boot.
The solution was to delay the start of gkrellmd.service on boot, by creating a file gkrellmd.timer in /etc/systemd/system/ (please note that the timer needs to have the same name as the service it controls):

  1. [Unit]
  2. Description=Delay starting of gkrellmd on boot
  4. [Timer]
  5. OnBootSec=1min
  7. [Install]

Then the original service needs to be disabled and the new timer enabled:

systemctl disable gkrellmd.service
systemctl enable gkrellmd.timer
This entry was posted in Linux and tagged , , . Bookmark the permalink.