Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.