Created
August 16, 2018 16:36
-
-
Save dhowdy/d3258c3240b5d9a77126a0e6d34b395a to your computer and use it in GitHub Desktop.
Simple systemd watchdog
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
cat <<EOF > /lib/systemd/system/[[[name]]].service | |
[Unit] | |
Description=[[[The Service to watch]]] | |
After=local-fs.target | |
[Service] | |
Type=simple | |
PIDFile=/var/run/[[[name]]].pid | |
ExecStart=/opt/[[[script.sh]]] | |
Restart=always | |
RestartSec=1 | |
StartLimitInterval=0 | |
StartLimitBurst=0 | |
[Install] | |
WantedBy=default.target | |
EOF | |
cat <<EOF > /opt/[[[script.sh]]] | |
#!/bin/bash | |
/path/to/executable with args | |
EOF | |
service [[[name]]] stop | |
systemctl daemon-reload | |
systemctl enable [[[name]]].service | |
service [[[name]]] start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment