Date: Mon, 26 Jan 1998 10:41:27 -0800 (PST) From: Matt Dillon <dillon@best.net> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/5572: major time step blows cron up Message-ID: <199801261841.KAA10811@flea.best.net>
next in thread | raw e-mail | index | archive | help
>Number: 5572 >Category: bin >Synopsis: A major time step blows cron up, runs thousands of processes >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jan 26 10:50:00 PST 1998 >Last-Modified: >Originator: Matt Dillon >Organization: Best Internet Communications >Release: FreeBSD 2.2.5-STABLE i386 >Environment: Loaded shell machines with lots of accounts and lots of cron jobs. >Description: If a major time step occurs, for example a backwards time step, cron will attempt to run every single job in between. This can result in cron starting thousands of jobs for the last N hours or N days, depending on how large a time step occured. >How-To-Repeat: Create some cron jobs and set the time backwards by a few hours. >Fix: The fix is included below. We check for nonsensical time steps and deal with them by resynchronizing cron's internal time tracking. *** LINK/cron.c Wed Sep 17 15:10:45 1997 --- cron.c Mon Jan 26 10:36:26 1998 *************** *** 229,234 **** --- 229,248 ---- cron_sleep() { register int seconds_to_wait; + /* + * Look for time step and don't run all the friggin cron jobs in + * between if a major backwards step occurs. Otherwise, a major + * time step (e.g. if the time gets messed up on the machine) may + * cause thousands of cron jobs to be run, especially if you have a lot + * of users. + */ + + seconds_to_wait = (int) (TargetTime - time((time_t*)0)); + + if (seconds_to_wait < -600 || seconds_to_wait > 600) { + cron_sync(); + } + do { seconds_to_wait = (int) (TargetTime - time((time_t*)0)); Debug(DSCH, ("[%d] TargetTime=%ld, sec-to-wait=%d\n", >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801261841.KAA10811>