To test the accessibility of a server, the ping command is used mostly. But it can happen, that a ping command is executed successfully, but the corresponding website is unreachable. To test this case, I have written a small script, that attempts with Wget, access the website.
#!/bin/bash # Check site every 10 seconds, log failed connection attempts in siteuptime.txt while true; do echo "Checking site..."; /usr/bin/wget "Domain To Test" --timeout 1 -O - 2>/dev/null | grep "Website Searchstring " || echo "The site is down" | date --iso-8601=seconds >> /The/Output/File.txt; sleep 1; done