From owner-freebsd-questions@FreeBSD.ORG Mon Jul 7 14:33:05 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 07F8E35A for ; Mon, 7 Jul 2014 14:33:05 +0000 (UTC) Received: from relay2.tomsk.ru (mail.sibptus.tomsk.ru [212.73.124.5]) by mx1.freebsd.org (Postfix) with ESMTP id 286302C08 for ; Mon, 7 Jul 2014 14:33:03 +0000 (UTC) X-Virus-Scanned: by clamd daemon 0.98.1 for FreeBSD at relay2.tomsk.ru Received: from admin.sibptus.tomsk.ru (account sudakov@sibptus.tomsk.ru [212.73.125.240] verified) by relay2.tomsk.ru (CommuniGate Pro SMTP 5.1.16) with ESMTPSA id 35940536 for freebsd-questions@freebsd.org; Mon, 07 Jul 2014 21:33:02 +0700 Received: from admin.sibptus.tomsk.ru (sudakov@localhost [127.0.0.1]) by admin.sibptus.tomsk.ru (8.14.7/8.14.7) with ESMTP id s67EX1hA077876 for ; Mon, 7 Jul 2014 21:33:01 +0700 (NOVT) (envelope-from vas@mpeks.tomsk.su) Received: (from sudakov@localhost) by admin.sibptus.tomsk.ru (8.14.7/8.14.7/Submit) id s67EX1Or077875 for freebsd-questions@freebsd.org; Mon, 7 Jul 2014 21:33:01 +0700 (NOVT) (envelope-from vas@mpeks.tomsk.su) X-Authentication-Warning: admin.sibptus.tomsk.ru: sudakov set sender to vas@mpeks.tomsk.su using -f Date: Mon, 7 Jul 2014 21:33:01 +0700 From: Victor Sudakov To: freebsd-questions@freebsd.org Subject: Re: Updating and displaying CMOS clock Message-ID: <20140707143301.GC77559@admin.sibptus.tomsk.ru> References: <20140707220727.B50382@sola.nimnet.asn.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140707220727.B50382@sola.nimnet.asn.au> Organization: AO "Svyaztransneft", SibPTUS X-PGP-Key: http://www.dreamwidth.org/pubkey?user=victor_sudakov X-PGP-Fingerprint: 10E3 1171 1273 E007 C2E9 3532 0DA4 F259 9B5E C634 User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jul 2014 14:33:05 -0000 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 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@sibptus.tomsk.ru