Skip to content

Instantly share code, notes, and snippets.

@MattLoyeD
Created August 27, 2016 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattLoyeD/11926e5a2c2f6662d8415b89ce3368d8 to your computer and use it in GitHub Desktop.
Save MattLoyeD/11926e5a2c2f6662d8415b89ce3368d8 to your computer and use it in GitHub Desktop.
Check website availability then reboot services if needed
#runs a check of your website http code response (Bad gateway, empty response, or service off) every half minute then send sms if reboot via Free Mobile API
jobjob()
{
var=`curl -I http://www.zogzog.com/ 2>/dev/null | head -n 1 | awk -F" " '{print $2}'`
if [[ -z "$var" ]] || [ "$var" == "502" ] || [ "$var" == "324" ]
then
curl -I "https://smsapi.free-mobile.fr/sendmsg?user=___&pass=___&msg=$var%20Serv%20Autorestart%20!";
sudo service nginx restart; sudo service php7.0-fpm restart;
else
echo "$var";
fi
}
jobjob;
sleep 25;
jobjob;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment