Re: Sleep Function

From: Date: Wed, 14 Feb 2024 13:40:18 +0000
Subject: Re: Sleep Function
Groups: php.gtk 
Request: Send a blank email to php-gtk+get-717@lists.php.net to get a copy of this message
you might look at doing it with external or system utilities that are already available. I'm not sure what platform you are on, but the cron daemon on unix systems provides this functionality. possibly using the 'at' command on windows platforms could work, having the program set a timer to call itself again before it exits. > I have been having tourble with boht the sleep and usleep function. I can only get them to 40 > sec and then they will cut off. This is even true with the micro seconds in the usleep function. > > Here is my code: > > do{ > $hour = date("G"); > $minute = date("i"); > $sec = date("s"); > print "$hour:$minute:$sec\n"; > usleep(100); // or us sleep(1); > }while($minute != "00"); > > This will stop on the 40th sec. Its not the 40th loop becuase usleep loops hundreds of > times but only quite on the 40th second. > > I am trying to set up a program to run every hour and this loop finds the hour on the hour > then continues to run.Incase someone starts the script say at 7:30. It will wait till 8:00 to run > the rest of the script. If there is a better way to do this please tell!!!! > > Thanks, > > Josh Seward > js389599@ohiou.edu

« previous php.gtk (#717) next »