cron(8) mis-feature with @reboot long after system startup

Tom Evans tevans.uk at googlemail.com
Fri Nov 25 11:06:10 UTC 2011


On Fri, Nov 25, 2011 at 7:02 AM, Jason Hellenthal <jhell at dataix.net> wrote:
>
> List,
>
> When using @reboot with cron you expect your proccesses to always start when the system boots up and only when the system boots. But long after the system in question had been booted, my @reboot processes ran again! after a (/etc/rc.d/cron restart). This is normally fine and dandy until one of your @reboot 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 hazardous.
>
> So with that said... is there a way we could actually make this run @reboot only ?
>
> 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 extension @boottime so it does not throw off current functionality ?
>
> Surely I could modify the scripts which do this but I find it unproductive and counter intuitive for the need to explain that @reboot means "When cron is restarted" even though the name means something completely opposite.
>
>
> Regards & Happy Thanks Giving.
>

Yep, @reboot is super dangerous if you don't realise it is 'crond
reboot' not 'system reboot'. We went through a period where all our
production servers crond kept dieing and getting restarted at odd
times.

The simplest solution is to not run stuff you want to run at boot time
through cron, and instead use rc.d, which is designed to do this.

Cheers

Tom


More information about the freebsd-hackers mailing list