Weird time changes, correct time and date but wrong hour
This has happened twice that I have noticed it. The first time it happened I assumed the CMOS battery ran out, so I changed it, which caused some issues that I had to fix. The CMOS battery is brand new ATM (since a few weeks ago), and it has happened again.
The hour changes maybe after booting up, but I don't always check, but the date and minutes and seconds are correct. For example, the real time now is 6:05:44, but my computer time is 'Fri Aug 1 23:05:44 CDT 2014'. I do have ntpd setup as follows: Code:
server 127.127.1.0 # local clock Code:
bash-4.2# ntpdate 0.north-america.pool.ntp.org CDT is the correct time zone, BTW. Oh, and there have been no power outages AFAIK. |
The hour offset appears to be the difference between local time and UTC (+5). This is typically caused by the hardware clock being set to local time and the OS thinks it is UTC or vice versa. If you dual boot, windows expects the hardware clock to be UTC. You can use the hwclock command to change the clock reference.
http://www.pc-freak.net/blog/how-to-...time-troubles/ |
Linux systems are generally set to UTC (Greenwich) time, and the time zone settings are used to adjust the display time to local time. Based on the difference between 18:00 (6 p. m.) and 23:00, I think that the former is local time and the latter is UTC. (That would be UTC -5; EDT is UDT -4.)
What are the outputs of Code:
hwclock |
Quote:
Code:
bash-4.2# hwclock I'm only running slackware64 14.1, no dual boot. |
Are you dual booting with windows
MS only uses the clock( on the MOBO) set to YOUR LOCAL time zone Linux can use MS's OR use it set to UTC setting the clock to UTC is preferred the clock is set to UTC then the desktop converts it to your LOCAL time instead of MS's way of converting your local to UTC for the web if you dual boot you HAVE!!!! to use Microsoft's way of setting the time !!!! if you do not windows will be off by the difference of the time zone |
I just checked the time in the UEFI firmware, it is correct at 7:52, here is the output of those commands now:
Code:
bash-4.2# hwclock |
Using UTC as the base time seems so annoying to me. But thats just me.
If "hwclock" is supposed to be internal clock, then its wrong... Go in to BIOS and set it to CDT. The reason you are getting two different times is because at all times, it picks up the BIOS clock FIRST, then attempts to connect to a time server for adjustments. If it picks up the time server, it "fixes" your time, but only in the OS, not in BIOS. If there's a hickup or something during that attempt and it fails, it leaves it with the BIOS time. There are a few systems that allow the BIOS time to get changed by time servers from the OS, but it requires support AND correct settings elsewhere. I personally make it a point that my BIOS time matches my local time and ignore time servers exactly because they don't always pick up. Then let OS deal with DST vs STD time. Edit: ooh, i should've quoted... This was based on the earlier message where hwclock gave UTC. If the BIOS is flip/flopping between, maybe you do have the setting to adjust the BIOS from the OS, and one of the time servers itself is giving wrong time... Maybe. |
If one of the time servers is bad, someone else would have noticed, because these are official servers:
http://www.pool.ntp.org/zone/north-america |
The hardware clock is local time.
Look at the contents of file /etc/adjtime. Is it local or UTC? |
It says local:
Code:
0.000000 1406940576 0.000000 |
shut the puppy down, go into BIOS and see what it says there.
|
I think it is obviously the difference between your localtime and UTC.
I always use UTC for the hardware clock, so will assume that in what follows (but will work the same if you select NO - Local in timeconfig). The idea here is to get all clocks and configs aligned to the same reference point. First: Code:
cat /etc/hardwareclock If not, as root: Code:
timeconfig Code:
First set the system clock: That should do it! |
If your CMOS time stays at the correct localtime, then it's probably an incorrect 'UTC' value in /etc/hardwareclock. Slackware's rc.S script use that in preference to the value stored in /etc/adjtime.
There are some issues with using ntp and a hwclock set to localtime that are discussed in http://www.linuxquestions.org/questi...me-4175477525/. If you find that the UEFI/CMOS time is also jumping by those 4/5 hours then I have some ideas on that, but we'll cross that bridge when we get to it. |
Thank you GazL, I think that thread is exactly the issue here, and it looks like the best solution is to set the system time to UTC. Alright, I'll do that.
I didn't realize the clock was being set to UTC otherwise I would have found the other thread. |
Here's a nice, confusing little treatise about time... well, about keeping time.
You have two clocks: the hardware clock and the software clock. The hardware clock is a chip (or part of a chip) on your motherboard kept running by the CMOS battery when the system is powered off (some motherboards will keep it running if the system is plugged in and turned off; I have a couple of those). The system clock is software managed by the kernel with interrupts (pretty much). When Slackware boots, the hardware clock is read by some code in /etc/rc.d/rc.S: Code:
# Set the system time from the hardware clock using hwclock --hctosys. Code:
cat /etc/hardwareclock For example, I'm in the eastern time zone, daylight time is in effect and my local time is four hours less than UTC (it's five hours when standard time is in effect): Code:
date As during start up -- boot -- when the system is shut down /etc/rc.0 has code to save the system time to the hardware clock: Code:
# Save the system time to the hardware clock using hwclock --systohc. If you're just rebooting, all that writing to the hardware clock is done by /etc/rc.d/rc.6 but the reading from the hardware clock and setting of the system clock is the same (handled by /etc/rc.d/rc.S). Should you keep your hardware clock on UTC? Well, yeah, you probably ought to (there's some movement afoot in kernel development to default all hardware clocks to UTC and be done with it -- hasn't happened yet but it just might so why fool around). NTP will keep your system clock on time (they're notorious for drifting all over the place). You configuration looks pretty much OK, but I'd recommend that you only use three servers and delete the iburst from them (they're not really necessary). You need to be root do the following. Others have recommended that you run timeconfig, setting your hardware clock to UTC and picking the correct time zone, which would be US central time. Yup, do that (be sure and stop NTPD first). The ntpdate utility is depreciated and you should use ntpd instead to set the system time correctly: Code:
ntpd -q Then you set the hardware clock: Code:
hwclock --systohc That should do it. You can start NTPD, wait about 5-10 minutes and run Code:
/usr/sbin/ntpq -pn When you see a display like this, with the + and *, you're synchronized and you'll stay that way (the one with the asterisk is the external server you're synchronized to). When you reboot or shut down, the correct time will be written to the hardware clock (then read from the hardware clock to set the software clock on the next boot). If that time drifts, you most likely have a bad battery (hey, it happens that you buy a new battery that's no good you know). You can check the next time you start the box from powered off by entering the BIOS (or UEFI) and see what time it is -- it should not have drifted more than 1,000 seconds even if powered off for a week or two. Over time, NTPD will "walk" your system clock into synchronization by using the drift value found in /etc/ntp/drift and keep it there; it takes a while for that to happen (like days, sometime a week or two) but it will get there if you leave the system running 24/7. Anyway, hop this helps some. |
All times are GMT -5. The time now is 06:44 AM. |