From: Caolan McNamara (Caolan.McNamara at domain ul.ie)
Date: Thu 20 May 1999 - 10:25:33 IST
On 19-May-99 Paul Jakma wrote:
>On Thu, 20 May 1999, Declan Shanaghy wrote:
> Now my impression of a cron job was a program the ran every so often and
> then exits, say every hour:
> 0 * * * * ~dek/seti/setiathome
>crond spawns the programme and waits for it to exit. if it doesn't
>exit cron can't do anything about it.
> But setiathome runs infinitely, downloading from the site and processing
> the data. (read the site for details)
> So how is a cron job setup to run a program and if its already running
> not run it again?
ordinarily i have a script in which i list all the programs i want running
continiously. If they are already running then don't run them again. Then
put that script in the crontab
sample entry for test2.sh is
if [ "`/bin/ps cxw | grep -c -h -s fdaemon`" = "0" ]; then
~caolan/bin/fdaemon ~caolan/.plan ~caolan/.planreal ~caolan/planlog &
crontab entry is
*/1 * * * * ~caolan/bin/test2.sh >> ~caolan/logerrors 2>&1
It has only failed onece, and that was because someone had hacked skynet and
replaced ps with a wrapper to hide a process. But had rewritten the ps wrapper
badly so it used the same temp dir for each ps. With the script the ps calls
were close enough together to get a collision causing run away processes (well
one extra an hour so hardly *run* away, more like a slow walk), seeing as the
output from ps was slightly incorrect.
>i think it's like rc5des. just run it in the background, eg leave it
>running on a console, or else background it with &.
Id still like to be able to run set and other programs inside a screen session
that i can run from crontab. That way i wouldnt have to either worry about huge
log files on output or worry that the program isnt doing anything because ive
sent its output to /dev/null.
Real Life: Caolan McNamara * Doing: MSc in HCI
Work: Caolan.McNamara at domain ul.ie * Phone: +353-61-202699
URL: http://www.csn.ul.ie/~caolan * Sig: an oblique strategy
Is the information correct?
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:13 GMT