[RndTbl] time off by 1 hour

Gilles Detillieux grdetil at scrc.umanitoba.ca
Tue Nov 20 13:30:03 CST 2012

On 20/11/2012 12:57 PM, Trevor Cordes wrote:
> On 2012-11-20 Gilbert E. Detillieux wrote:
>> I don't think ntpdate and ntpd modify the system clock, only the
>> runtime clock.  So, my guess is that the two clocks are not in
>> synch.  Normally, RedHat-ish systems (including Fedora) write back
>> the runtime clock setting to the system clock on shutdown, but
>> perhaps this isn't happening for some reason.
> Ya, that was it.  I fixed the sys clock then wrote it to the hwclock
> and rebooted and it seems to be correct now, thanks!
> So the big mystery is why is the Fedora shutdown not writing the
> correct time to the hwclock?  I too thought that was automatic.  I've
> never had this problem on other Fedora systems.  Anyone know what
> program/rpm/script is responsible for this?  Some quick greps of etc
> aren't finding me anything.

In RHEL5, this was done in the start function of /etc/init.d/ntpd, after 
running ntpdate to initially sync with the time server, so not at 
shutdown time apparently.  Also, it was only done if SYNC_HWCLOCK was 
set to yes in /etc/sysconfig/ntpd, and the default value seems to be 
no.  In Fedora 17, the whole init.d/rc.d business is replaced with 
systemd, whose config files live in /lib/systemd/system.  The 
ntpdate.service config file there sets 
ExecStart=/usr/libexec/ntpdate-wrapper, and that script seems to do the 
whole hwclock --systohc thing if SYNC_HWCLOCK=yes, this time in 
/etc/sysconfig/ntpdate, but again the default seems to be no.  In both 
cases, the hwclock synching only happens if ntpdate returns 0, so no 
synching, even with everything setup correctly, if ntpdate fails.  As 
far as I can tell, neither RHEL5 nor F17 call hwclock at any point 
during shutdown, which seems odd/bass-ackwards.

Finally, a bit of a source of frustration is that in Fedora, the 
ntpdate-wrapper script ignores any settings in /etc/sysconfig/clock, so 
that can cause some issues if hwclock doesn't pick the appropriate 
default.  It's supposed to use the last value of --utc or --localtime 
that was used, which apparently is stored in /etc/adjtime, but in 
practice I've found that when switching between OSes on a multi-boot 
system, Fedora seems to get confused about whether you wanted to use 
local time or UTC.

Gilles R. Detillieux              E-mail: <grdetil at scrc.umanitoba.ca>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/
Dept. Physiology, U. of Manitoba  Winnipeg, MB  R3E 0J9  (Canada)

More information about the Roundtable mailing list