[Gllug] Cron revisited

Neil Fryer neil.fryer at 12snap.com
Thu Oct 24 12:22:23 UTC 2002


Thank you sooooo much to all who helped me out, I really do appreciate this
and hope that I can return the favour sometime.

Kind Regards
Neil

-----Original Message-----
From: will [mailto:will at hellacool.co.uk]
Sent: 24 October 2002 13:20
To: gllug at linux.co.uk
Subject: Re: [Gllug] Cron revisited


Neil Fryer wrote:
> Hi again
> 
> Ok, here is the command that I want to run ever two minutes, but I have to
> make sure that it completes before it runs again. Can someone please be
kind
> enough  to show me how I would do this, as I am really baffled here.
> Thanks in advance.
> 
> 1 * * * * /usr/local/jre1.3.1_04/bin/java -cp
/apps/cf/htdocs/java_scheduler
> WinForward >> /apps/cf/htdocs/java_scheduler/WinForward.log >

Firstly, this will run your program on the first minute of every hour.  See:

http://www.lysator.liu.se/~forsberg/linux/cron.html

for a good cron syntax guide, or just man crontab.

Also, you can specify that a process should have finished before it runs
another 
one in cron.  Cron will run the next process blindly.  There are a couple of

solutions I can think about, but probably more I can't :-)

One way could be to write a wrapper script that creates a file when it runs
then 
deletes the file when it has finished.  The script would check for the
existence 
of this file before running the process.  Personally I would do it in perl, 
because I know perl, but it is probably better to do it in shell.  Something
like:

if file exists "/var/run/WinForwardRunning"
     print "Process is still running"
     exit script
else
     create file "/var/run/WinForwardRunning"
     run shell command "/usr/local/jre1.3.1_04/bin/java -cp blablabla"
     remove file "/var/run/WinForwardRunning"
     exit script

Alternatively, don't so it in cron, and write a daemonised process (again, I

would use perl because I know it :-) to run the command, the advantage of
this 
that I see would be that the daemon could have better rescheduling
possibilities 
than the cron example, but then I am crud at shell so that might not be
true. 
Also, this could be overkill :-)

Will.


-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list