Bruce Marshall wrote:
On Thursday 23 February 2006 13:17, Anders Johansson wrote:
Anders Johansson wrote:
I know you know this Jerry, but I still have to point this out: this won't run every 15 seconds, it will run at 15 second intervals.
Silly me. Of course the "whatever task" could be launched in the background, which would bring it closer to "every 15 seconds", which might be good enough
But perhaps the way Jerry wrote it would be best.... Since it would allow the program to finish each time.
Or... if it is observed that the program takes 3 seconds to run (as an average) then the sleep time could be reduced to 12 secs. and thus if the job took 5 secs. on occasion, no harm would be done.
At least that's the way I would do it (not knowing what the OP wants to accomplish)
While all my code-writing experience lies outside of *nix, if the OP can tolerate a small amount of drift, and the task runs in under 15sec, perhaps the script Jerry suggested could simply execute the task 4 times, at 15sec intervals, and the script would be called onver per minute by cron. That way (assuming certain of my assumptions are correct), there would be a possibility for some drift between the repetitions within a given minute, but cron should 're-sync' the task at the top of every minute. If the task runs close to 15sec, there's a possibility of overlap at the top of each minute, when cron calls the script again. But if this is tolerable, it might work for the OP's purposes.