Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Run a cron process more than every minute' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Run a cron process more than every minute
Authored by: bdm on May 17, '07 03:42:57AM

Something like this is the way to go if only shell tools are to be used, but this solution has problems. If the open is fast enough, the time in seconds might be the same multiple of dt that it was before. Then sleep 0 will be executed and the open will be executed too soon. A quick fix would be to test for 0 sleep times and change them to dt. Better would be to monitor the execution starts explicitly. Get the time at the beginning, say "start" and at iteration i sleep until time start+dt*i where the first iteration is i=1.


[ Reply to This | # ]
Run a cron process more than every minute
Authored by: viadd on May 17, '07 09:00:55PM

The expression "${dt} - \( ${now} % ${dt} \)" always gives a value from 1 to 15 (for dt = 15). The '%' operator takes the remainder when now is divided by 15, which is always in the range 0-14 , and 15 minus that puts it in the 15-1 range, respectively.

Thus there won't be any cases of sleep 0, even if open takes 0 seconds.

[ Reply to This | # ]