RE: Cron - Any advanced options?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I use a lock file for this purpose...something like this

 

#Check if the file exits at the start

 

FILE1=/usr1/tmp/your_cron.lck
if [ -e $FILE1 ]
   then
        echo 'Already running -This one aborted!'
        exit
fi
touch $FILE1
chmod 666 $FILE1

 

do the do here with appropriate waits

 

sleep 1
rm $FILE1
exit code stuff here


Your mileage may vary,  etc..... 

 
> Date: Thu, 23 Apr 2009 13:45:57 +0530
> From: kurianmthayil@xxxxxxxxx
> To: redhat-list@xxxxxxxxxx
> Subject: Cron - Any advanced options?
> 
> Hi All,
> 
> I am using RHEL 5.2 Server and I have 3 cron jobs enabled and all are
> relating to RSYNC. Now, all of these scripts are run once in every 7 minutes
> all day. The problem occurs when the scripts doesn't finish to execute in 7
> minutes. This will result in starting execution of the same script again and
> this will malfunction the setup.
> 
> Is there an option in CRON, which always check if CRON has started the
> process and is already running? Cron should execute the script only if the
> the process isn't running already. Any hints on this?
> 
> Regards,
> 
> Kurian Thayil.
> -- 
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list

_________________________________________________________________
Windows Live™ Hotmail®:…more than just e-mail.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_more_042009-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subjecthttps://www.redhat.com/mailman/listinfo/redhat-list


[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux