i want to run the following php script continously in specified intervals of time and can be set by a user using a form. how to do this?
<p>//i need to run this script repetadly and the time interval can be set by a user</p>

<p>// checking the internet connection</p>

<pre><code>if (!$sock = fsockopen("www.google.com", 80, $errno, $errstr,20))
    {
?&gt;
&lt;script type="text/javascript"&gt;

alert("Connection problem");

&lt;/script&gt;

&lt;?php       
    }
</code></pre>

<p>// retriving data from database and checking the site is down</p>

<pre><code>else
    {
    for($i=0;$i&lt;count($res);$i++)
        {
        $fp=fsockopen($res[$i]['url'],80,$errno,$errstr,30);
        if($fp==false)
            {
 ?&gt;
 &lt;script type="text/javascript"&gt;

 alert("Website is down");

 &lt;/script&gt;

 &lt;?php
</code></pre>

<p>// writing data to database and sending mail</p>

<pre><code>mail($email[0]['email_id'],"website is down",$res[$i]['url']." is down");
    $inputs=array('website_id'=&gt;$res[$i['website_id'],
    'date'=&gt;date("Y-m-d H:i:s"),'reason'=&gt;"website down");
$obj3-&gt;addLog($inputs);
         }
    }
}
sleep(300);
}
</code></pre>
