In the last episode (Sep 02), Paul Schmehl said: > --On September 2, 2008 6:03:51 PM +0200 Albert Shih wrote: > > Le 02/09/2008 à 08:45:52-0700, ElihuJ a écrit > >> Hi all. I have a question about cron jobs that seem to be running > >> to long or with multiple copies of itself. For example, I have a > >> backup script that I run that seems to make multiple copies of > >> itself. If I view the running processes I see numerous instances > >> of the same cron job. Is there something I can do to limit this > >> from happening? When it does, it drains my CPU and some of my > >> other processes are non responsive. Any help would be appreciated. > >> Thank you. > > > > That's not the to cron to do that. > > Actually, it could be. If the script is started by cron and is still > running when the next job is scheduled, cron will start another > process. If they're both still running when the next job is > scheduled, you'll have three processes running, etc., etc.
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 ) -- Dan Nelson [EMAIL PROTECTED] _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"