title: Make loops in php
body: <p>I am actually making a script to check whether game server is online or offline!</p>
  
  <p>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.</p>
  
  <p>The code i have now is : </p>
  
  <pre><code>/* 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 = '&lt;div class="callout callout-success"&gt;&lt;h4&gt;Server Online!&lt;/h4&gt;&lt;p&gt;Server is online, you can start playing with us!&lt;/div&gt;';
      $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 = '&lt;i class="fa fa-circle text-success"&gt;&lt;/i&gt; Online';
  
  
  } else {  //Else display N/A instead if throwing 404 and reuining the page!
  
      $serverStatus = '&lt;div class="callout callout-danger"&gt;&lt;h4&gt;Server Offline!&lt;/h4&gt;&lt;p&gt;Server is Offline, we are working on to fix it! Will start to work soon.&lt;/p&gt;&lt;/div&gt;';
      $memClans = "N/A";
      $onPlayers = "N/A";
      $players = "N/A";
      $usedram = "N/A";
      $info = '&lt;i class="fa fa-circle text-danger"&gt;&lt;/i&gt; Offline';
  
  }
  </code></pre>
  
  <p>Can you please tell me how to execute this same script every 20 minutes and output the information?</p>
  
  <p>Thanks in advance</p>