Created
April 27, 2014 11:08
-
-
Save oazabir/11343018 to your computer and use it in GitHub Desktop.
Check if a site is up and running
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 | |
if wget -nv -p $1 &> $2 | |
then | |
if cat $2 | grep -i "error" | |
then | |
echo "Site has error" | |
cat $2 | grep -i -B 1 "error" | mail -s "$3" $4 | |
else | |
echo "Site OK" | |
fi | |
else | |
sleep 10 | |
if ! wget -nv -p $1 &> $2 | |
then | |
echo "Site is down" | |
echo "Site down" | mail -s "$3" $4 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment