From owner-freebsd-hardware@FreeBSD.ORG Thu Mar 19 15:21:02 2009 Return-Path: Delivered-To: freebsd-hardware@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B82341065676 for ; Thu, 19 Mar 2009 15:21:02 +0000 (UTC) (envelope-from andre@albsmeier.net) Received: from outside.albsmeier.net (outside.albsmeier.net [80.81.31.28]) by mx1.freebsd.org (Postfix) with ESMTP id 275FE8FC1A for ; Thu, 19 Mar 2009 15:21:01 +0000 (UTC) (envelope-from andre@albsmeier.net) Received: from schlappy.albsmeier.net (57.44.166.190.f.p.codetel.net.do [190.166.44.57] (may be forged)) (authenticated bits=128) by outside.albsmeier.net (8.14.2/8.14.3) with ESMTP id n2JF9YSx031409; Thu, 19 Mar 2009 16:09:36 +0100 (CET) (envelope-from andre@albsmeier.net) Received: from schlappy.albsmeier.net (schlappy.albsmeier.net [127.0.0.1]) by schlappy.albsmeier.net (8.14.3/8.14.3) with ESMTP id n2JF9WU2006697; Thu, 19 Mar 2009 16:09:32 +0100 (CET) (envelope-from andre@schlappy.albsmeier.net) Received: (from andre@localhost) by schlappy.albsmeier.net (8.14.3/8.14.3/Submit) id n2JF9WXB006696; Thu, 19 Mar 2009 16:09:32 +0100 (CET) (envelope-from andre) Date: Thu, 19 Mar 2009 16:09:32 +0100 From: Andre Albsmeier To: freebsd-hardware@freebsd.org, won.derick@yahoo.com Message-ID: <20090319150932.GA2174@schlappy.albsmeier.net> References: <800496.48763.qm@web45816.mail.sp1.yahoo.com> <200902141838.n1EIcwQX009259@lurza.secnetix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200902141838.n1EIcwQX009259@lurza.secnetix.de> X-Echelon: PGP, r00t, Fax, 747, VHF X-Advice: Drop that crappy M$-Outlook, I'm tired of your viruses! User-Agent: Mutt/1.5.18 (2008-05-17) Cc: Subject: Re: Hardware clock is not SYNC'ed with kernel clock by ntpdate? X-BeenThere: freebsd-hardware@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: General discussion of FreeBSD hardware List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2009 15:21:03 -0000 On Sat, 14-Feb-2009 at 19:38:58 +0100, Oliver Fromme wrote: > Won De Erick wrote: > > ... > > > However, how should I make this automatic, something that will update > > the CMOS clock everytime the kernel clock is syncronized with a NTP > > server? Do I need to make changes on the variables below? > > You seem to misunderstand. The CMOS clock _is_ always > updated when you run ntpd. You do not have to change > anything. Hmm, my experience is different here. I have 17 FreeBSD machines which are all running ntpd (btw, no /etc/wall_cmos_clock). When being rebooted, they sync the time with ntpdate before starting ntpd. Somtimes I noticed the time being stepped by several seconds (up to 50). I observed that the higher the previous uptime had been, the bigger the stepping during the following reboot was. While ntpd keeps the kernel time perfectly in sync with our stratum-1 server the CMOS clocks slowly drift away. The higher the uptime, the bigger the drift. I am now using this ugly hack to sync the kernel time to the CMOS clock (settimeofday() sets both) before reboot and the problem never appeared again: #include #include #include #include int main( void ) { struct timeval tv; if( gettimeofday( &tv, NULL ) != 0 ) err( EX_DATAERR, "gettimeofday" ); if( settimeofday( &tv, NULL ) != 0 ) err( EX_DATAERR, "settimeofday" ); return 0; } A cleaner way might be to call resettodr() in subr_clock.c just before rebooting. If there are easier/cleaner ways to keep CMOS time in sync, I will be happy about any suggestions. -Andre