Timed systemd service restarts
April 15, 2017
If you have ever wanted to do periodic restarts of a service, and for whatever reason you don’t want to use cron, you can use systemd to accomplish that task.
Systemd has numerous knobs and you can do this task in several different ways. Here’s one that I got to work for me:
Concept
Create a two hour timer which activates a target every two hours. Our target is a one-shot service which restarts the main service.
Here’s the code (gist):
two-hour.timer
two-hour.service
You can check the current state of timers using systtemctl
.
Goodbye.