in reply to Pause Loop
How accurate do you want the delay to be? If you embed a 1 hour delay in the loop along with the commands that are being run, your script will run every 1 hour + however long the commands take, so your schedule will slip continuously. A slightly different formulation of the loop will account for that without having to accurately time how long the commands take:
my $endTime = time() + 3600; while( 1 ) { # Do stuff, # Do more stuff # And more # And more # And more # And more sleep 1 while time() < $endtime; $endtime = time() + 3600; }
The inner sleep loop will consume negligible cpu but will ensure that you don't sleep longer than you need to, even if the active part of the script varies in how long it takes to run.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pause Loop
by fenLisesi (Priest) on Apr 28, 2007 at 10:07 UTC | |
|
Re^2: Pause Loop
by salva (Canon) on Apr 28, 2007 at 09:24 UTC | |
by BrowserUk (Patriarch) on Apr 28, 2007 at 09:43 UTC | |
by salva (Canon) on Apr 28, 2007 at 10:49 UTC | |
by BrowserUk (Patriarch) on Apr 28, 2007 at 11:25 UTC |