PHP:
<?php
$url = 'yoursite.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
$retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (200==$retcode) {
echo "Site is Up";
} else {
$to = "Your Email ID Here";
$subject = "Uptime Alert";
$message = "Your website is down take a look @ it";
$from = "uptime@yoursite.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Current Status : Down";
}
?>
Usage : name it as uptime.php
*/15 * * * * php -q /home/cPanelUsername/public_html/uptime.php
Credits : Original Devs I just combined 2 snippets
Just put the script on cron job of every 15 mins from a free cpanel host and you dont need to spend $10 a month on pingdom