Gentoo Archives: gentoo-user

From: "Håkon Alstadheim" <hakon@×××××××××××××××.no>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Getting a valid /etc/adjtime while using ntpd ?
Date: Thu, 17 Mar 2016 20:03:13
Message-Id: 56EB0D73.7070903@alstadheim.priv.no
In Reply to: Re: [gentoo-user] Getting a valid /etc/adjtime while using ntpd ? by Bill Kenworthy
1 On 03/17/2016 02:03 PM, Bill Kenworthy wrote:
2 > On 17/03/16 20:26, Alan McKinnon wrote:
3 >> On 17/03/2016 08:50, Håkon Alstadheim wrote:
4 >>> I have a server SUPPOSED to be running 24/7, but every once in a while
5 >>> during a prolonged absence the box will go down. The Real Time Clock
6 >>> will drift, and in the rush to get the box up again I let everything
7 >>> boot up automatically and get both wrong time on the main systems, and
8 >>> different times on the various systems.
9 >>>
10 >>> My setup has a main server which does NTP, but with no direct link to
11 >>> the outside. Router&firewall /have/ to be booted booted later (dumb
12 >>> setup, don't ask), after which I can finally get correct time from NTP.
13 >>>
14 >>> NTP initiates "11 minute mode", which makes /etc/adjtime useless as far
15 >>> as I understand. Anybody have a /correct/ way to account for RTC drift
16 >>> on a box running ntpd? Right now I have a ---file in
17 >>> /etc/cron.d/time-bad like so:
18 >>> * * * * * root adjtimex -S 5 >/dev/null 2>&1 </dev/null
19 >>> ---
20 >>>
21 >>> Combined with an old-fashioned setup for hwclock during boot and
22 >>> shutdown. This feels really wrong, and I have no idea what I am doing.
23 >>>
24 >>> TLDR: Anybody have a /correct/ way to account for RTC drift on a box
25 >>> running ntpd?
26 >>>
27 >>>
28 >>
29 >> When the box was off, all questions of accurate ntp tracking are moot.
30 >> ntp is designed around the idea that every second happens but from your
31 >> machine's point of view they didn't happen since it was powered down.
32 >>
33 >> I would go the really simple route and force ntpdate to run once during
34 >> boot up before ntpd is started, thereby avoiding the entire issue.
35 Why can't I have proper drift information for my RTC ("bios clock") ?
36 The old way ( where "system-time as set by ntp" minus "RTC time"
37 gives "drift-value" written to /etc/adjtime ) used to work perfectly
38 for me for several years. Is there no canonical way of getting that
39 these days?
40
41 My problem is that my WAN connection can not be brought up until well
42 after the main server is up (stupid I know, but rearranging things
43 entails a major overhaul). Thus a bios clock without drift information
44 gives me a choice between ntpdate (which messes up my logs) and ntp with
45 incremental adjustments (which might leave clocks wrong for several days).
46
47 I really need the logs to be on the same clock for all systems. Don't
48 ask, just assume I know why it's called bleeding edge . I also really
49 need sub-minute accuracy on all clocks. I suppose I should try running
50 ntpdate on everything once the WAN connection is up, just to see how bad
51 the mess is.
52
53
54 >> Sometimes correctness really doesn't matter, this looks like one of those.
55 >>
56 >>
57 >> alan
58 >>
59 > add a cheap gps setup as the reference clock to the server,
60 That sounds like a real option. I have an old Nokia N900 lying around
61 with a broken usb-port, so I'd need to solder in a power lead. Any
62 pointers for how to read time signal from the gps on a maemo system?
63 > or even
64 > better is a dedicated time server (either a real one or a raspberry
65 > pi/gps) on the network if you have internal connectivity. Going super
66 > cheap, but not quite as accurate for me was an arduino and rtc on a
67 > bluetooth pan for when the network was down but I needed a reference (to
68 > power up the real server :).
69 >
70 >
71 > google "arduino time server" for plenty of options :)
72 >
73 This led me to finding some serial-port connected gps modules.
74 Serial-ports I have, so this is sounding good. 35 to 40 euro for a gps
75 device when hwclock and /etc/adjtime should give ballpark-correct time
76 on boot makes me hate this though.
77
78 This reminds me one reason I need a valid time is my DVB-T TV-receiver
79 card. It should be possible to find a clock source in the broadcast
80 stream. I'll research that first, while I leave my "adjtime -S 5 " hack
81 running, even though I still don't know if that makes any sense at all.
82 At least now there is something different from "0.0000" in the
83 driftvalue, which gives me some hope I'm on to something.

Replies

Subject Author
Re: [gentoo-user] Getting a valid /etc/adjtime while using ntpd ? Alan McKinnon <alan.mckinnon@×××××.com>