With the following shell script we will:

1. By every 5 minutes will be checked if the w3m is getting the “200 OK” output.

2. If yes, then the script stops.

3. If no, then the command mail sends an email message warning the administrator about this issue.

4. The “/root/mailmsg.txt” file is where your customized warning message will be. You can certainly place it anywhere else if you wish so.

So, where’s the beef? Here it is, add the following code to your crontab (or write a separate file and point it in your crontab):

 */5 * * * * w3m -dump_head my-hi.com | grep -q '200 OK' || echo 'Your website is down' | mail -s 'Your website is down' admin@domainxyz.com < /root/mailmsg.txt