Walker News

Simple Trick Used To Monitor Website Uptime

There are many sites offer service to check and track website uptime, but I haven’t found one that allows user to run check at every minute except the paid premium plan.

So, I make a simple Linux shell script (below) that uses wget to check website uptime (replace blue texts with your own value accordingly):

DMSG="Unknown at "`date`

wget -O $WGETLOG http://www.walkernews.net 2>>$WGETLOG

[ $? -ne 0 ] && mail -s "$DMSG" email@example.com <$WGETLOG

If the Linux web hosting server allows you to schedule cronjob, send email, and run wget at command prompt, then configure crontab to auto execute the shell script every minutes:
  • If the website is down (caused by failure of web server/Apache, PHP, MySQL, etc), it will send an alert to notify you at the given email address.
  • If the Internet connection to the web hosting server is down, the shell script can’t detect it and thus can’t alert you :(

Alternatively, power on a Linux machine 24×7 at home or somewhere else to run the shell script. Though this way allows it to detect both Internet connection and website problem (therefore can notify you via email alert), but it can’t tell which side of the Internet connection is down (unless running another check using ping) and you’ve to find a Linux machine running 24×7 :(

If that is not your ideal solution, then go subscribe free service to track website uptime (at longer interval) or get a paid premium service with great features (e.g. email + SMS alert, monthly / daily reports, online statistics, multiple checks from different sites, etc).

Custom Search

  1. carl 31-08-11@15:51

    You could use Nagios check_http for this.
    You don’t even have to do a full Nagios install if you just want to run the test.

    See http://nagiosplugins.org/man/check_http

2018  •  Privacy Policy