Hardware clock being forced to UTC time
I have four systems running Slackware current with the hardware clock being forced to UTC time. I'm in the eastern time zone (EDT) and the system times are being sync by NTP. If I set the hardware clock to my current system time, it drift back to the UTC time after a few hours. Even after running:
Code:
hwclock --localtime --systohc Code:
0.000000 1379470547 0.000000 |
Try running timeconfig again to make sure that your /etc/localtime is correct.
|
Pat,
I ran 'timeconfig' and selected my timezone. However, there was no change to the /etc/hardwareclock file. Actually, the file was update, but the content is the same where my hardware clock is listed as 'localtime'. Is there anyway to read to content of '/etc/localtime'? |
Just after running timeconfig on one of the systems, here is the current time shift:
Code:
hwclock -r |
Thanks Pat. timeconfig did the trick.
|
Turns out the timeconfig didn't work. localtime is set to the correct timezone, however the hardware clock is being set to UTC time. This is not an issue if the system is shutdown/restart successfully since rc.0/rc.6 sets the hardware clock. However, if I loose power, the system starts with UTC time. This is shown in the dmesg:
Code:
[ 6.239104] rtc_cmos 00:07: setting system clock to 2013-09-29 17:12:51 UTC (1380474771) |
Quote:
Mine is kept in localtime, but my dmesg also shows the time the system clock is set to in UTC. That's normal. |
Contents of both hardwareclock and adjtime below. To my knowledge, everything is set to local time. I think it start doing this after the 3.9.x kernel.
Code:
cat /etc/hardwareclock Code:
cat /etc/adjtime |
Just checked all my systems which are on kernel 3.10.12 and they all show the same time symptom. All systems are set to localtime and the timezone is correct. This could have gone unnoticed for a long time as it only occurs when system is not shutdown correctly (ie, i loose power).
Here is the senario: 1. The system boots with hardware clock in local time 2. The system time is also set to local time 3. The system time stays at local time and is updated by NTP 4. The hardware clock is pushed to UTC while the system is on (I am still unable to determine how long this takes to occur) 5. If the system shuts down/reboots normally, during the shutdown the hardware clock is set back to localtime by rc.0/rc.6. 6. If I abruptly loose power without shutting down, the hardware clock remains in UTC so at the next boot, the system is set to UTC. This cause NTP to fail since the time is too far off. Also, this causes the both the system and hardware clock to perpetually drift forward (in my case by 4 hrs) if I keep loosing power. |
Sounds like you have a cron job that is periodically updating the hardware clock and forcing UTC.
|
Quote:
I rebooted one of my systems 3 hours ago and the hwclock which was fine at boot is now 4hrs ahead. This system does not have the cron.monthly script which update the time. Also, all users except for root have cron disabled. Here is the content of the that script to rule it out: Code:
cat /etc/cron.monthly/update_bios_clock.sh |
Run a background job that reads the hardware clock every 10 minutes or so and reports when it sees a big change. Hopefully you can correlate that with activity that got logged within that interval.
|
I did just that and I caught when the hardware clock change (within a 10min window), but no clue as to what changed it. There is no cron, nothing in the syslog or message file. Nothing anywhere.
Code:
DATE: Mon Sep 30 16:38:51 EDT 2013 Code:
ls -l /usr/bin/crontab |
How about...
Code:
ps -ef | grep ntpd Code:
grep ntp /etc/dhcpcd.conf |
One of the recent kernels introduced these new options, which sound as if they may be relevant.
CONFIG_RTC_HCTOSYS: If you say yes here, the system time (wall clock) will be set using the value read from a specified RTC device. This is useful to avoid unnecessary fsck runs at boot time, and to network better. CONFIG_RTC_SYSTOHC: If you say yes here, the system time (wall clock) will be stored in the RTC specified by RTC_HCTOSYS_DEVICE approximately every 11 minutes if userspace reports synchronized NTP status. Also check out the help text on CONFIG_RTC_HCTOSYS_DEVICE: This device should record time in UTC, since the kernel won't do timezone correction If you're running your hw_clock on localtime then you probably want to avoid these new RTC options in your kernel config (especially the second one). P.S. Both appear to be set to Y in config-generic-3.10.12.x64 |
All times are GMT -5. The time now is 03:49 AM. |