On Tue, 2 Sep 2008 11:40:37 -0500 Dan Nelson <[EMAIL PROTECTED]> wrote:
> I use the lockfile command ( from the procmail port ) to ensure that > recurring cron jobs don't overlap if one run takes too long. For > example, to run mrtg on a 1-minute cycle but prevent multiple mrtgs > from running if one run takes longer than 1 minute: > > * * * * * /usr/local/bin/lockfile -r 1 -l 3600 /tmp/mrtg.LCK && > ( nice -19 /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg ; > rm /tmp/mrtg.LCK ) > > The -l 3600 tells lockfile to remove any lockfiles over an hour old ( > if the machine was rebooted during an mrtg run for example ) > you could also handle stale lock-files, without installing procmail, like this: LCK=/tmp/foo.LCK find $LCK -mtime +3600s -delete if ![ -f "$LCK" ] ; then touch "$LCK" [ -f "$LCK" ] && foo rm "$LCK" fi Presumably the lockfile command also eliminates the race between testing for, and creating, the lock-file, but that's not really needed here. _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"