wget
is an HTTP client, so you're making a web request to http://mysite.com. You'll have to check the exit status of the wget
command: if the request is successful, the exit status will be "0", and otherwise if it's not successful.
So, your check script may look something like:
#!/bin/bash
wget -O /dev/null -q http://mysite.com
if [ "$?" -ne "0" ]; then
echo "Web site is down!"
fi
If you're not really sure about shell scripting, it might be better to use a service that will perform the check, along the lines of Pingdom.
Update:
Instead of using wget
, it may be better to use curl
. Something like this:
curl -sL -w "%{http_code}" http://mysite.com -o /dev/null
This will return the HTTP response code, so you can do more obvious controlled comparisons (i.e., curl will return 404, whereas wget will return some non-zero exit code that you have to figure out from documentation)