Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Nov 2011 12:51:36 -0800
From:      Tim Kientzle <tim@kientzle.com>
To:        Jason Hellenthal <jhell@DataIX.net>
Cc:        hackers@freebsd.org, Dieter BSD <dieterbsd@engineer.com>
Subject:   Re: cron(8) mis-feature with @reboot long after system startup
Message-ID:  <7FD0AD28-B509-4E1F-BE82-713F85F17C1D@kientzle.com>
In-Reply-To: <20111126195305.GC2368@DataIX.net>
References:  <20111125175344.233450@gmx.com> <20111126195305.GC2368@DataIX.net>

next in thread | previous in thread | raw e-mail | index | archive | help

>>> 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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7FD0AD28-B509-4E1F-BE82-713F85F17C1D>