Skip to content

Instantly share code, notes, and snippets.

@oazabir
Created April 27, 2014 11:08
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 oazabir/11343018 to your computer and use it in GitHub Desktop.
Save oazabir/11343018 to your computer and use it in GitHub Desktop.
Check if a site is up and running
#!/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