Ping a url

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
Watch

edmarriner

Established Member
Impact
4
is there anyway or waebist to basicly ping the url say every 30 mins?

thanks

ed
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
0
•••
Hey Ed,

Here's what we'll do. Assuming you have access to the ever ample PHP, crontabs and access to shell_exec(), we'll begin.

The following is a script that will run the ping, and return a result.
PHP:
<?php
/* 
Script written by Steve Castle (http://www.stscac.com)
Modified from http://shat.net/php/nqt/nqt.php.txt

For the purpose of this example, the filename of this file (PHP_SELF) will be named ping.php and located in server path erver/path/to/script/

The "$domain" variable is the domain name you are going to be checking.  Use  the domain name without the protocol.
(Good = namepros.com, Bad = http://www.namepros.com)
*/
$domain = "namepros.com";
function message($msg){
echo "<font face=\"verdana,arial\" size=1>$msg</font>";
flush();
}
function ping($domain){
message("<p><b>Ping Results:</b><blockquote>");
if (! $msg .= trim(nl2br(`ping -c5 '$domain'`))) #bugfix
  $msg .= "Ping failed. Host may not be active.";
$msg .= "</blockquote></p>";
message($msg);
}
ping($domain);
?>
The following is the crontab that needs to be added to your server, so the PHP script above can be run every 1/2 hour.
Code:
30 * * * * server/path/to/script/ping.php

This only checks the results every 30 minutes. To report the results, you would have to email them or add them to a database.

Hope this starts you off in the right direction.

Cheers B-)!

-Steve
 
0
•••
0
•••
Dynadot — .com TransferDynadot — .com Transfer
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com
Catchy
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back