[RndTbl] time off by 1 hour

Gilbert E. Detillieux gedetil at cs.umanitoba.ca
Tue Nov 20 13:47:12 CST 2012


On 2012-11-20 13:30, Gilles Detillieux wrote:
> 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.

Actually, RHEL5 has the following line in /etc/init.d/halt...

[ -x /sbin/hwclock ] && action $"Syncing hardware clock to system time" 
/sbin/hwclock $CLOCKFLAGS

The value of CLOCKFLAGS is calculated earlier in the same script, based 
on the UTC and ARC variables set in the /etc/sysconfig/clock config 
file.  A similar line exists in the halt script in RHEL6, except it no 
longer sources /etc/sysconfig/clock, but just has a hard-coded option.

That seems to have disappeared with the switch to systemd in Fedora. 
So, the best bet seems to be to configure ntpdate to work correctly, so 
you at least get the clock synch'ed on startup.

> 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.
>


-- 
Gilbert E. Detillieux		E-mail: <gedetil at muug.mb.ca>
Manitoba UNIX User Group	Web:	http://www.muug.mb.ca/
PO Box 130 St-Boniface		Phone:  (204)474-8161
Winnipeg MB CANADA  R2H 3B4	Fax:    (204)474-7609


More information about the Roundtable mailing list