Skip to content

Instantly share code, notes, and snippets.

@vzool
Created October 31, 2022 12:19
Show Gist options
  • Save vzool/a829ce48aac0fc9ee65a74758eda0968 to your computer and use it in GitHub Desktop.
Save vzool/a829ce48aac0fc9ee65a74758eda0968 to your computer and use it in GitHub Desktop.
#!/bin/bash
# cronjob:
# * * * * * /root/bin/watch-service apcupsd > /dev/null
service=$@
/bin/systemctl -q is-active "$service.service"
status=$?
if [ "$status" == 0 ]; then
echo "$service - OK"
else
echo "$service - Starting..."
/bin/systemctl start "$service.service"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment