Monitor Your Website Automatically From Cron
View Markdown Other ArticlesArticle written by a human: Mike Cardwell - Want to hire me? Get in touch
I modified the title of my Blog the other day and it reminded me of a little trick I have been using to monitor my website. I received an email alert stating that my website was returning unexpected content. To do this, I created a really basic cron job like this:
MAILTO=webmaster@example.com
3 * * * * if [[ `wget -q -O - https://www.grepular.com/|grep "Mike Cardwell | Blog"` == "" ]]; then echo "Website response unexepected"; fi
Once an hour it takes a look at https://www.grepular.com/ and if it doesn't receive a page that contains "Mike Cardwell | Blog" then it warns me that my website is returning unexpected content and that I should take a look at it. It's so simple that it can be done entirely inside cron without having to write an external script to do the check.
Want to hire me? Get in touch