Created
March 24, 2022 21:06
-
-
Save mpql/3661ff5f293c2bc6f3eec6fdc96cf13d to your computer and use it in GitHub Desktop.
Script to check service status and hit URL ; intended to be cron'd
This file contains hidden or 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
#!/bin/bash | |
service=${1} ; | |
url=${2} ; | |
if [[ -z "${url}" ]] || [[ -z "${service}" ]] | |
then | |
echo 'Argument missing.' ; | |
echo 'Usage: check-service.sh [servicename] [push URL]' ; | |
exit | |
fi | |
/bin/systemctl -q is-active "${service}.service" ; | |
status=$? ; | |
if [[ "${status}" == 0 ]] ; then | |
curl --silent --max-time 6 --output /dev/null "${url}" ; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment