From owner-freebsd-hackers@FreeBSD.ORG Sat Nov 26 20:51:43 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 149E61065670 for ; Sat, 26 Nov 2011 20:51:43 +0000 (UTC) (envelope-from tim@kientzle.com) Received: from monday.kientzle.com (99-115-135-74.uvs.sntcca.sbcglobal.net [99.115.135.74]) by mx1.freebsd.org (Postfix) with ESMTP id E74168FC12 for ; Sat, 26 Nov 2011 20:51:42 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.4/8.14.4) id pAQKpcSu023728; Sat, 26 Nov 2011 20:51:38 GMT (envelope-from tim@kientzle.com) Received: from [192.168.2.119] (CiscoE3000 [192.168.1.65]) by kientzle.com with SMTP id cdpg9t5h85aym8447adjzwzaew; Sat, 26 Nov 2011 20:51:37 +0000 (UTC) (envelope-from tim@kientzle.com) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: Tim Kientzle In-Reply-To: <20111126195305.GC2368@DataIX.net> Date: Sat, 26 Nov 2011 12:51:36 -0800 Content-Transfer-Encoding: quoted-printable Message-Id: <7FD0AD28-B509-4E1F-BE82-713F85F17C1D@kientzle.com> References: <20111125175344.233450@gmx.com> <20111126195305.GC2368@DataIX.net> To: Jason Hellenthal X-Mailer: Apple Mail (2.1251.1) Cc: hackers@freebsd.org, Dieter BSD 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 List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Nov 2011 20:51:43 -0000 >>> Add an option to cron to check lastlog and if within 5 or 10 minutes >>> of the last reboot, then call run_reboot_jobs(). >>=20 >> Depending on timestamps might be okay as a temporary quick-and-dirty >> workaround, but there is likely to be a case where it will also do = the >> wrong thing. ??What if you need to restart cron within the 5-10 = minutes? >>=20 >> Maybe something like: rc script sets a flag, cron_reboot script = checks >> and resets flag. ??The flag could be a file ("> = /tmp/rebooting_system"). >> Better yet, a run-the-reboot-script command line option could be = added >> to cron. >=20 > cron(8) already creates a pid file. Maybe it wouldn't be so bad to = just check the timestamp of that before creating its new pid file along = with comparing to system boottime so we could make an accurate measure = whether it should or should not run the @reboot extension at least down = to 1 minute. Timing-based approaches like this tend to be brittle and fail in strange ways. Remember that "boot time" basically means "run by /etc/rc". Is there any way for /etc/rc.d/cron to notice that it's being run by /etc/rc and pass an extra flag to cron in that case? (If not, then perhaps /etc/rc should set some kind of marker when it starts --- such as an environment variable or a=20 file on disk --- that scripts such as /etc/rc.d/cron can use to distinguish boot-time startup from manual startup.) Tim