From owner-freebsd-hackers@FreeBSD.ORG Fri Nov 25 16:09:10 2011 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1EF73106566B for ; Fri, 25 Nov 2011 16:09:10 +0000 (UTC) (envelope-from Cy.Schubert@komquats.com) Received: from idcmail-mo1so.shaw.ca (idcmail-mo1so.shaw.ca [24.71.223.10]) by mx1.freebsd.org (Postfix) with ESMTP id D5BFA8FC0C for ; Fri, 25 Nov 2011 16:09:09 +0000 (UTC) Received: from pd2ml1so-ssvc.prod.shaw.ca ([10.0.141.139]) by pd2mo1so-svcs.prod.shaw.ca with ESMTP; 25 Nov 2011 09:09:09 -0700 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=n2W5COKzyCYKBlY96L0A3my6r0xTlngINTUh0kppeyk= c=1 sm=1 a=FNQ37yD0mI0A:10 a=QrugwKR0C_UA:10 a=wAGQQ9Az6v0A:10 a=BLceEmwcHowA:10 a=ICAaq7hcmGcA:10 a=kj9zAlcOel0A:10 a=2Er20JxOMs3KTlR2XTlUiQ==:17 a=6I5d2MoRAAAA:8 a=M0VwM5ZyAAAA:8 a=BWvPGDcYAAAA:8 a=Lt116vQMuqQpeSF3j_UA:9 a=CjuIK1q_8ugA:10 a=SV7veod9ZcQA:10 a=Xclt7nbD0wcA:10 a=V7tsTZBp22UA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Received: from unknown (HELO spqr.komquats.com) ([24.68.73.211]) by pd2ml1so-dmz.prod.shaw.ca with ESMTP; 25 Nov 2011 09:09:08 -0700 Received: from slippy.cwsent.com (slippy [10.1.1.91]) by spqr.komquats.com (Postfix) with ESMTP id BBE4A46B74; Fri, 25 Nov 2011 08:09:07 -0800 (PST) Received: from slippy (localhost [127.0.0.1]) by slippy.cwsent.com (8.14.5/8.14.5) with ESMTP id pAPG97dT008848; Fri, 25 Nov 2011 08:09:07 -0800 (PST) (envelope-from Cy.Schubert@komquats.com) Message-Id: <201111251609.pAPG97dT008848@slippy.cwsent.com> X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.3 From: Cy Schubert X-os: FreeBSD X-Sender: cy@cwsent.com X-URL: http://www.komquats.com/ To: Doug Barton In-Reply-To: Message from Doug Barton of "Fri, 25 Nov 2011 00:42:25 PST." <4ECF54F1.50203@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 25 Nov 2011 08:09:07 -0800 Cc: Jason Hellenthal , hackers@FreeBSD.org Subject: Re: cron(8) mis-feature with @reboot long after system startup X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Cy Schubert List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2011 16:09:10 -0000 In message <4ECF54F1.50203@FreeBSD.org>, Doug Barton writes: > On 11/25/2011 00:12, Cy Schubert wrote: > > In message <20111125070241.GA7915@DataIX.net>, Jason Hellenthal writes: > >> List, > >> > >> When using @reboot with cron you expect your proccesses to always start wh > en > >> the system boots up and only when the system boots. But long after the sys > tem > >> in question had been booted, my @reboot processes ran again! after a (/et > c/r > >> c.d/cron restart). This is normally fine and dandy until one of your @rebo > ot > >> jobs needs to contain a process that purges files "files that are already > in > >> use by a running daemon since the system has not rebooted" and becomes haz > ard > >> ous. > >> > >> So with that said... is there a way we could actually make this run @reboo > t o > >> nly ? > >> > >> Compare the system boottime (kern.boottime) to the current time and if it > is > >> greater than ?5 minutes? do not run on any @reboot's ? or add yet another > ext > >> ension @boottime so it does not throw off current functionality ? > >> > >> Surely I could modify the scripts which do this but I find it unproductive > an > >> d counter intuitive for the need to explain that @reboot means "When cron > is > >> restarted" even though the name means something completely opposite. > > > > I don't see how cron could run reboot jobs again while running. It calls > > run_reboot_jobs only during startup. Could it be possible that cron died on > > > your system and you restarted it? > > Please read the OP again carefully. You're right. Sorry. It was late, after a long night of O/T. Let's try this again.... Add an option to cron to check lastlog and if within 5 or 10 minutes of the last reboot, then call run_reboot_jobs(). Alternatively, any cron job that needed to run after reboot could do this itself. Changing the behaviour by default would change the semantics of @reboot, altering the behaviour of cron jobs which rely on the brokenness. What if both behaviours are wanted on the same system? Unlikely, as I can't see anyone relying on this broken behaviour. Having said that, I'm sure there are cron jobs that do rely on the broken behaviour, so it may be best to simply deprecate the broken behaviour and make one or the other a command line option. Apologies for not reading the original posting carefully. -- Cheers, Cy Schubert FreeBSD UNIX: Web: http://www.FreeBSD.org