Last active
August 29, 2015 13:57
-
-
Save ktraff/9689892 to your computer and use it in GitHub Desktop.
Check the status of a website and send an email if it is down
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
#!/bin/bash | |
# Script that checks the health status of a website and | |
# sends notifications if the website is unavailable. | |
HOST='website.com' | |
status=`curl -L -o /dev/null --silent --head --write-out '%{http_code}\n' $HOST` | |
if [ $status != 200 ]; then | |
echo "$HOST received a status of $status." | mail -s "$HOST is down" "johnsmith@gmail.com" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment