Simple systemd watchdog
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