1 |
On Sat, 2006-02-11 at 13:07 -0700, Duncan wrote: |
2 |
> Mark Knecht posted |
3 |
> <5bdc1c8b0602110941y446deb24qc519fcb40298136a@××××××××××.com>, excerpted |
4 |
> below, on Sat, 11 Feb 2006 09:41:20 -0800: |
5 |
> |
6 |
> > Hello, |
7 |
... |
8 |
> > QUESTION 4: |
9 |
> > |
10 |
> > Does ntpd actually update the system clock, or is it another layer yet |
11 |
> > on top. If I use ntpd and then do hwclock -w does an accurate time get |
12 |
> > written to the hardware clock? |
13 |
> |
14 |
> I don't like the term "system" clock in this context, because it's |
15 |
> ambiguous as to whether you are referring to hardware or software. That's |
16 |
> why I used system/software clock or the like a couple times above, to make |
17 |
> it absolutely clear which I was referring to. |
18 |
> |
19 |
> That said, "system clock" normally refers to the software clock that the |
20 |
> system uses while running, and yes, ntpd /does/ update it directly -- |
21 |
> well, sort-of. <g> Don't worry, the confusion is normal and under the |
22 |
> circumstances entirely understandable, but there's a logical explanation |
23 |
> that makes sense once you understand what's going on. |
24 |
> |
25 |
> Here's the deal. ntpd was developed to be used in situations where |
26 |
> various running programs might be making critical assumptions about the |
27 |
> system time -- namely that it always moves forward, never backward. To |
28 |
> have the time move backward, if the machine's an online server in some |
29 |
> applications, would be /very/ /bad/! Thus, by default and if at all |
30 |
|
31 |
From the ntpd man page: |
32 |
This may on occasion cause the clock to be set backwards if the local |
33 |
clock time is more than 128 s in the future relative to the server. |
34 |
In some applications, this behavior may be unacceptable. If the -x |
35 |
option is included on the command line, the clock will never be stepped |
36 |
and only slew corrections will be used. |
37 |
|
38 |
|
39 |
> possible (if the time isn't off by days or years), ntpd will normally |
40 |
> choose to /skew/ the time, adjusting how fast the machine advances time by |
41 |
> a few parts per million, rather than stepping it either forward or |
42 |
> backward by seconds/minutes/hours/days/whatever at a time. |
43 |
> |
44 |
> On Linux, the kernel is actually responsible for keeping time, and has a |
45 |
> userland API that ntpd uses to skew the time, telling the kernel to |
46 |
> measure say 999 998 instead of 1 000 000 ticks if the clock is slightly |
47 |
> fast, until real time catches up, or 1 000 005 ticks instead of 1 000 000, |
48 |
> if the clock is slightly slow and needs to catch up to real time. So, |
49 |
> yes, ntpd /is/ adjusting the time, but ideally, not fast enough that |
50 |
> anything can really notice it. |
51 |
> |
52 |
> Note also that ntpd keeps track of how far your system has drifted from |
53 |
> the rest of the world, each time it checks in, and uses that to tweak |
54 |
> system clock speed accordingly. If you go adjusting the clock yourself |
55 |
> while ntpd is running, it's going to think something's drastically wrong |
56 |
> with the system that it gained or lost so much time so fast, and will |
57 |
> REALLY put the screws on that skew, thereby REALLY screwing up the system |
58 |
> for a few days, as ntpd adjusts the clock first one way, then the other, |
59 |
|
60 |
man ntpd: ... once the clock has been set, an error greater than |
61 |
1000s will cause ntpd to exit anyway. |
62 |
|
63 |
> until it figures out the real drift of the system once again. This is why |
64 |
> I said turn off ntpd before you go screwing with the clock, even the |
65 |
> little bit of setting the hardware clock from the software clock and then |
66 |
> the software clock from the hardware clock, as you do by running |
67 |
> /etc/init.d/clock restart, because even the 100th of a second leap that |
68 |
> might happen setting the time between the two, would be enough to screw up |
69 |
> ntpd's calculations and set your time swinging that much more than it |
70 |
> should, for a day or two. Once it knows how accurate your system is on |
71 |
|
72 |
man ntpd: ... about 2,000 s for each second the clock is outside the |
73 |
acceptable range. ... |
74 |
|
75 |
In spite of the above precautions, sometimes when large frequency errors |
76 |
are present the resulting time offsets stray outside the 128-ms |
77 |
range and an eventual step or slew time correction is required. If |
78 |
following such a correction the frequency error is so large that the |
79 |
first sample is outside the acceptable range, ntpd enters the same state |
80 |
as when the ntp.drift file is not present. The intent of this |
81 |
behavior is to quickly correct the frequency and restore operation to |
82 |
the normal tracking mode. In the most extreme cases ( time.ien.it comes |
83 |
to mind), there may be occasional step/slew corrections and subsequent |
84 |
frequency corrections. It helps in these cases to use the burst |
85 |
keyword when configuring the server. |
86 |
|
87 |
------------------------ |
88 |
Just had a couple of issues with that. :) |
89 |
|
90 |
|
91 |
> -- |
92 |
> Duncan - List replies preferred. No HTML msgs. |
93 |
> "Every nonfree program has a lord, a master -- |
94 |
> and if you use the program, he is your master." Richard Stallman in |
95 |
> http://www.linuxdevcenter.com/pub/a/linux/2004/12/22/rms_interview.html |
96 |
> |
97 |
> |
98 |
Cheers Duncan, |
99 |
-- |
100 |
Tres Melton |
101 |
IRC & Gentoo: RiverRat |