From owner-freebsd-bugs Mon Jan 26 10:50:03 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA04417 for freebsd-bugs-outgoing; Mon, 26 Jan 1998 10:50:03 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: (from gnats@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA04378; Mon, 26 Jan 1998 10:50:01 -0800 (PST) (envelope-from gnats) Received: from flea.best.net (root@flea.best.net [206.184.139.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA03299 for ; Mon, 26 Jan 1998 10:42:43 -0800 (PST) (envelope-from dillon@flea.best.net) Received: (from dillon@localhost) by flea.best.net (8.8.8/8.7.3) id KAA10811; Mon, 26 Jan 1998 10:41:27 -0800 (PST) Message-Id: <199801261841.KAA10811@flea.best.net> Date: Mon, 26 Jan 1998 10:41:27 -0800 (PST) From: Matt Dillon Reply-To: dillon@best.net To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/5572: major time step blows cron up Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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: