UNIX Bash – Website Monitor

| | | | | | | |
for i in $(curl -s -L cnn.com |egrep --only-matching 'http(s?):\/\/[^ \"\(\)\<\>]*' | uniq)
do
    curl -s -I "$i" 2>/dev/null | head -n 1 | cut -d' ' -f2
done
curl -Is http://www.google.com | head -n 1
HTTP/1.1 200 OK
curl www.websiteToTest.com -s -f -o /dev/null || echo "Website down." | mail -s "Website is down" admin@example.com

Reference: http://unix.stackexchange.com/questions/84814/health-check-of-web-page-using-curl

All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.