Re: [PHP] Run script every 30 seconds



Or, you could run two scripts every minute ... one that starts immediately, and one that sleeps for 30s before starting.

-- Mitch



Dave Hamber wrote:
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 ?


.



Relevant Pages

  • Sys::Syslog writes to /dev/console instead of /dev/log
    ... sleeps for thirty seconds ... ... script slips into a state where it doesn't log anything to syslog. ... and here is strace output from a functioning case and then from a ... ioctl for d ...
    (comp.lang.perl.misc)
  • Re: Problems running script as service
    ... and then sleeps for 20 seconds, then looks for things to do, then sleeps ... > If I run the script in the foreground, ... > I'm using srvany with the following parameter: ...
    (microsoft.public.windows.server.scripting)
  • Re: on startup scripts
    ... Alas it sleeps then continues to load gnome ... Currently looking into placing a script inside the ... in seconds) to the startup time of gnome on your machine. ...
    (Ubuntu)
  • Re: utter newbie expect question
    ... exp_sends, but then the script would not run at all, but that helped ... me debug a bit. ... So now I have exp_sends, conservative mode off, and a load of sleeps ...
    (comp.lang.tcl)
  • Problems running script as service
    ... It does some things and then sleeps for 20 seconds, then looks for things to do, then sleeps again. ... If I run the script in the foreground, ... A friend of mine stopped by this morning and is having the same problem. ... I'm using srvany with the following parameter: ...
    (microsoft.public.windows.server.scripting)