Frequent job scheduling like cron

Net Llama! netllama
Mon May 17 11:53:39 PDT 2004


On 09/14/03 13:13, Michael Hipp wrote:
> I have a job I need to run automatically at about every 5 minutes. Cron 
> could certainly do that. But if the job should run long, I don't want it 
> to be started again while a previous instance is still running. And if 
> the job should run 4.5 minutes, I don't necessarily want it to run again 
> in 30 seconds, tho that wouldn't be fatal.
> 
> I could just use a script with a delay at the end before it loops back 
> to the top, but that's crude and not particularly reliable.
> 
> Any clever, robust way to do this?

with cron & an a more intelligent script :)

seriously, you can have your script create some kind of lock file, and then 
whenever it runs, check for the existence of the lock file before 
proceeding.  if it doesn't find one, then it should create a new lock file, 
do its thing, and when completed, delete its lock file.

if you don't want it to do anything if its been more than a specific since 
the last one finished, you'll need to add some time/date stamp analysis 
functionality to the script so that it can determine how long its been 
since the last job ran.  perhaps creating both a lock file, which is 
transient, and another file that just gets the output from 'date' cat'ed 
into it when the last job finishes.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L. Friedman                       	       netllama at linux-sxs.org
Linux Step-by-step & TyGeMo: 		    http://netllama.ipfox.com

   1:25pm  up 1 day, 19:53,  2 users,  load average: 0.01, 0.11, 0.12



More information about the Linux-users mailing list