From owner-freebsd-current@FreeBSD.ORG Wed Jun 2 13:07:12 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 35C8816A4CE for ; Wed, 2 Jun 2004 13:07:12 -0700 (PDT) Received: from ack.Berkeley.EDU (ack.berkeley.edu [128.32.206.66]) by mx1.FreeBSD.org (Postfix) with ESMTP id F1C4143D48 for ; Wed, 2 Jun 2004 13:07:11 -0700 (PDT) (envelope-from mhunter@ack.Berkeley.EDU) Received: (from mhunter@localhost) by ack.Berkeley.EDU (8.11.3/8.11.3) id i52K78c03360; Wed, 2 Jun 2004 13:07:08 -0700 (PDT) Date: Wed, 2 Jun 2004 13:07:08 -0700 From: Mike Hunter To: Charles Swiger Message-ID: <20040602200708.GA1847@ack.Berkeley.EDU> References: <20040602134523.GA26835@genius.tao.org.uk> <20040602140148.GA27036@genius.tao.org.uk> <20040602140923.GA27070@genius.tao.org.uk> <20040603011806.E25331@gamplex.bde.org> <20040602161148.GA3067@dan.emsphone.com> <9C375698-B4CD-11D8-9C6A-003065ABFD92@mac.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9C375698-B4CD-11D8-9C6A-003065ABFD92@mac.com> User-Agent: Mutt/1.5.6i cc: current@freebsd.org Subject: Re: Problems with periodic scripts in jails [Cron /usr/libexec/save-entropy] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2004 20:07:12 -0000 On Jun 02, "Charles Swiger" wrote: > On Jun 2, 2004, at 12:11 PM, Dan Nelson wrote: > >A nice addition to cron might be a way to tell it that certain jobs > >should be single-instance. I know about half of my cron jobs look > >like: > > > >/usr/local/bin/lockfile -r 1 -l 3600 /tmp/runjob.LCK && ( runjob ; rm > >/tmp/runjob.LCK ) > > > >and it'd be handy if cron would do this internally (no physical > >lockfiles needed). The least intrusive way would be to add a magic > >variable similar to MAILTO; NO_OVERLAP=1 or something. Anyone up for a > >Junior Userland Hacker project? :) > > If a cron job (eg, a shell script) doesn't perform whatever locking it > needs for itself, what happens when someone runs the script by hand? For stuff that I do, when you run the script by hand, you see when it's done by returning to the prompt, so you're not likely to run it until it's finished. > What happens to cron's "internal locking" if one restarts cron? Why > jump through hoops to avoid creating lockfiles if you're going to need > some persistent mechanism to track locks when/if cron terminates, > anyway? I've restarted cron once due to a time zone error, other than that, cron tends to restart when the machine is booted, and that's about it :) Maybe some day I'll be hardcore enough to set up systems that put cron at risk, but I think for the average user it's not a huge concern. > My suggestion would be to move the invocation of lockfile into the > runjob script itself, so that your crontab is smaller and less > cluttered, and your runjob scripts become smart enough to fend for > themselves. That's a good suggestion. I do think that cron itself strongly influences the need for locking in some situations, and that it therefore might be appropriate to put functionality to deal with it in cron. I drooled when I read the initial suggestion :) Mike