Can I configure systemd services to be periodically restarted?
4 votes c/questions Posted by zPlus — 4 votes, 2 commentsSource

I have a running process that, for various reasons, needs to be restarted once a day. The job is managed with a systemd .service file, which looks like this




and I’ve setup also crontab to run systemctl restart <service> once a day. I would like to know if there is an option that I can add to my .service file for restarting the service periodically, such that I can have all the configuration in a single file and basically not use crontab anymore.

Ah good find! Thank you for the link. I would prefer something that I can configure in the same service file though, if this is possible at all, because my interest it to only have one configuration file. I am already using crontab, and changing from crontab to another configuration file (such as .timer) is not really what I’m looking for. I’d like to keep everything inside the same file, if it makes sense.

In the manpage[1] I found a couple of options, RuntimeMaxSec and WatchdogSec, but I’ve never used them before and I don’t even understand if they’re really relevant to my question.