I am actually making a script to check whether game server is online or offline!
As of now the script i have made which does not check the server every 20 minutes. I want the script to check whether the server is online or offline and out put the information.
The code i have now is :
/* Server Information
–––––––––––––––––––––––––––––––––––––––––––––––––– */
$server_Debug = "9332";
$server_Port = "9339";
$server_key = "UCSGL";
/* Get's IP
–––––––––––––––––––––––––––––––––––––––––––––––––– */
$server_Ip = file_get_contents('http://bot.whatismyipaddress.com/');
/* API installation
–––––––––––––––––––––––––––––––––––––––––––––––––– */
if ($isOnline = @fsockopen($server_Ip,$server_Port,$errno,$errstr)) {
fclose($isOnline); //Establish connection to api if server online
$serverStatus = '<div class="callout callout-success"><h4>Server Online!</h4><p>Server is online, you can start playing with us!</div>';
$memClans = file_get_contents("http://$server_Ip:$server_Debug/$server_key/inmemclans");
$onPlayers = file_get_contents("http://$server_Ip:$server_Debug/$server_key/onlineplayers");
$players = file_get_contents("http://$server_Ip:$server_Debug/$server_key/totalclients");
$usedram = file_get_contents("http://$server_Ip:$server_Debug/$server_key/ram");
$info = '<i class="fa fa-circle text-success"></i> Online';
} else { //Else display N/A instead if throwing 404 and reuining the page!
$serverStatus = '<div class="callout callout-danger"><h4>Server Offline!</h4><p>Server is Offline, we are working on to fix it! Will start to work soon.</p></div>';
$memClans = "N/A";
$onPlayers = "N/A";
$players = "N/A";
$usedram = "N/A";
$info = '<i class="fa fa-circle text-danger"></i> Offline';
}
Can you please tell me how to execute this same script every 20 minutes and output the information?
Thanks in advance