Re: Run script every 30 seconds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry, slight adjustment, make that $t=time()-31; in the first line so that the script runs immediately.


> You could run the script as a daemon. man daemon.
>
> The sloppy way of running the script every 30 seconds would be to use sleep(30), but that would cause the script to run at 30 seconds + execution time.
>
> If you make a loop like this you could get around that:
>
> $t=time()+31;
> while(true){
>     if(time()>$t+30){
>         $t=time();
>             YourMainScriptFunction();
>     }
>     else usleep(1000); //adjust to how often you want to check
> }

On 30/10/2006 17:29 Ahmad Al-Twaijiry wrote:
Hi everyone,

I have a script that I want it to run every 30 seconds, the problem is
that cronjob can run every 1 minute only, do you have any solution ?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux