You should be able to see from the output of wget --spider ...
why wget
has failed. That information is emailed to the user running the script or, if you use
[email protected]
you can redirect it to your email account for review.
If there are spurious network or DNS errors you can do a double check to see if unavailability was temporary, and thereby reducing the number of false positives:
wget --spider -a /var/tmp/wget_test.log http://mywebsite.com || (sleep 10; wget --spider http://mywebsite.com ) || php sendsms.php
Note that I have made the first try, append output to a log file (instead of printing to stderr). This way you don't get an email every 10 minutes if things run fine.
Every wget
run first prints a date-timestamp and url when it tries that url.
You will be able to review all runs that fail the first wget
and pass the second by matching the date-timestamp from the emailed output of the second wget
to that from the log file.
--spider
really necessary? If the site is large, it could take a long time, and if the first page works, you already know Apache is working. Are there particular pages (perhaps CGI scripts) which may malfunction for other reasons? Then maybe use (one of) those as your test case.