9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: andrey mirtchovski <mirtchov@cpsc.ucalgary.ca>
To: 9fans@cse.psu.edu
Subject: [9fans] cron and timesync
Date: Thu, 17 Jul 2003 12:53:50 -0600	[thread overview]
Message-ID: <Pine.LNX.4.44.0307171223310.7478-100000@fbsd.cpsc.ucalgary.ca> (raw)

There is a race between the cron daemon and timesync that hit me pretty
badly for the past two days.

The problem comes from the fact that timesync does not set the system's
real-time clock. On one of the machines here the RTC was behind a few hours,
so when it went through /rc/bin/cpurc the following happened:


    ...                                 # time set by rtc (1am)
    aux/timesync -n ntp.ucalgary.ca     # time still 1am
    ...
    auth/cron                           # time still 1am
    ...
    ...                                 # after a few (micro)seconds the time
                                        # is reset to the current time (say
                                        # 10am) as reported by the ntp server

cron gets initialized with 'last' time being 1am and the next time it wakes
up it tries to run all cron jobs in between 1am and 10am, effectively
crashing my machine.

i have modified timesync.c and added a -w option to write to /dev/rtc, but
then decided it'd be simple to run 'date -n > /dev/rtc' once daily from
cron.

in the example below cron started some 2000 jobs:


% date; date -n
Thu Jul 17 12:36:55 MDT 2003
1058467015
% echo 1057467015 > /dev/rtc
% aux/timesync -r
% date
Sat Jul  5 22:50:24 MDT 2003
% auth/cron
% ps | grep cron
bootes          648    0:00   0:00     172K Sleep    cron
% aux/timesync -n ntp.cpsc.ucalgary.ca
% date
Thu Jul 17 12:38:11 MDT 2003
%
% date -n > /dev/rtc # otherwise it'll happen again on reboot
% # wait a minute or so ...


andrey



             reply	other threads:[~2003-07-17 18:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-17 18:53 andrey mirtchovski [this message]
2003-07-17 19:26 ` rog
2003-07-17 19:47 ` Dan Cross
2003-07-17 20:21   ` Geoff Collyer
2003-07-17 20:57     ` David Presotto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0307171223310.7478-100000@fbsd.cpsc.ucalgary.ca \
    --to=mirtchov@cpsc.ucalgary.ca \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).