Updating and displaying CMOS clock
Victor Sudakov
vas at mpeks.tomsk.su
Mon Jul 7 14:33:05 UTC 2014
Ian Smith wrote:
> >
> > What's the command to update the CMOS clock to the time of the kernel
> > clock?
> >
> > ntpd does a good job of keeping the accurate time in the kernel clock,
> > but from my experience, this time is not propagated to the CMOS clock
> > which lives its own life. As a result, there is a large time skew
> > everytime the box is rebooted, which prevents from Kerberos login
> > until the kernel clock is synchronized.
>
> That shouldn't be happening. There may be some hardware problem with
> your RTC if you haven't messed with the sysctl settings (see below).
> Could be a borderline battery, poor quality 32768Hz timebase or ..
Yes, the RTC in that box is not good, therefore the problem. Last time
I rebooted, it had drifted maybe 10-15 minutes for a period of several
months' uptime.
> > In other words, what's the FreeBSD equivalent of the Linux
> > "hwclock --systohc" command?
>
> People have pointed out incantations with date that will do the job, but
> it really shouldn't be necessary.
>
> > And no, contrary to popular belief, the correction of the CMOS clock
> > does not happen automatically in FreeBSD even if ntpd is running.
>
> Yes, it does. Has since 2.2.6 anyway, whether or not ntpd is running.
Sorry, I doubt that.
>
> In 8.x /var/log/messages gets spammed with RTC update messages every
> half hour, if you had booted with verbose messages:
>
> Jul 7 19:34:41 t23 ntpd[65982]: kernel time sync status change 6001
> Jul 7 19:45:29 t23 ntpd[65982]: kernel time sync status change 2001
> Jul 7 19:46:22 t23 kernel: ts_to_ct(1404762382.687179418) = [2014-07-07 19:46:22]
I see ntpd acting here.
> In 9.x there's a new sysctl debug.clocktime to enable such verbosity; I
> turned it on about 3 hours ago after seeing this thread, suspended and
> resumed to confirm it working, then restarted ntpd for good measure:
I don't run ntpd on that box, just ntpdate hourly.
[dd]
>
> Do these match yours? And set sysctl debug.clocktime=1 and report back.
On a 8.4-RELEASE box, I have set sysctl debug.clocktime=1 and waited
for three hours with no trace of any adjustment to the RTC. During
these three hours, ntpdate has been run three times.
However, as soon as I did "sysctl `sysctl -e machdep.adjkerntz`", I
received the following in /var/log/messages:
Jul 7 21:28:34 <kern.crit> fw kernel: ts_to_ct(1404743314.713060410) = [2014-07-07 14:28:34]
What is the conclusion? I think if you are not running ntpd, the only way
to adjust the RTC is running "sysctl `sysctl -e machdep.adjkerntz`".
--
Victor Sudakov, VAS4-RIPE, VAS47-RIPN
sip:sudakov at sibptus.tomsk.ru
More information about the freebsd-questions
mailing list