Last active
July 3, 2024 09:36
-
-
Save goyalankit/e8223915c382b98cfe99fff57bbc52dc to your computer and use it in GitHub Desktop.
Systemd unit files to restart service every two hours.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Service that restarts my spread_goodness.service every two hours. | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/systemctl try-restart spread_goodness.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=2hour timer | |
[Timer] | |
OnBootSec=0min | |
OnCalendar=0/2:00:00 | |
Unit=two-hour.service | |
[Install] | |
WantedBy=basic.target |
Thanks . To check your format;
Valid -> systemd-analyze calendar '0/2:00:00'
Invalid -> systemd-analyze calendar '*/2:00:00'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm currently trying to understand how timers work within systemd and this was very helpful and straight to the point. Thanks for sharing. ^^