You are not logged in.

#1 2012-12-21 05:35:19

douglasr
Member
Registered: 2012-12-21
Posts: 19

[SOLVED] System Clock Issues (Wrong UTC?)

**RESOLVED -- SEE END FOR FIX


Hello everyone.

First off I'd like to say that I am thrilled to be here. I've been an Ubuntu user for a few months now, but decided that it was time to take a trip down the rabbit hole and see all that Linux had to offer--and to that end I switched to Arch. And I must say that I have nothing but positive things to say of it. The documentation on the Arch Wiki was phenomenal in helping me get started on the process, and the installation of it has proved to be a very enjoyable learning experience.

With that said, I have run into a bit of a snag, and after perusing the documentation on the Wiki, as well as running a few Google searches and searches of this particular forum, am no closer to a solution that when I started, so here I am. The problem is with my clock.

Okay, so I live in the Eastern United States, and as a result have my local time set as Eastern, and I have my hardware clock running UTC. Here is the problem. . . For whatever reason, the time displayed on my clock is five hours behind. Perplexed, I decided to see if I had set up my time zone info incorrectly and ran the "timedatectl status" command, and the results were really strange. A copy paste of the output is here:

      Local time: Thu, 2012-12-20 19:27:02 EST
  Universal time: Fri, 2012-12-21 00:27:02 UTC
        RTC time: Fri, 2012-12-21 00:27:02
        Timezone: America/New_York
      UTC offset: -0500
     NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
      DST active: no
Last DST change: EDT → EST, DST became inactive
                  Sun, 2012-11-04 01:59:59 EDT
                  Sun, 2012-11-04 01:00:00 EST
Next DST change: EST → EDT, DST will become active
                  the clock will jump one hour forward
                  Sun, 2013-03-10 01:59:59 EST
                  Sun, 2013-03-10 03:00:00 EDT

As you can see, the time zone is set correctly to America/New_York (originally US/Eastern, but I changed it to try and resolve the problem--to no effect, obviously). However here is where it gets strange. As I type this, it is 00:27 local time. My computer has decided to use the local time for UTC, and then subtracts five hours (as I live in UTC -5) to get the local time that it displays.

I've tried rerunning the hwclock --systohc --utc command, to no avail.

If anyone has any input as to why my computer is confusing UTC and local time, and any way I could fix it, I would greatly appreciate it.

I could just change my timezone to UTC - 0, that would cause my system to display the right time (I think) but I'd rather actually fix the problem, instead of simply covering it up with a band aid, if it is possible.

Thank you,
Douglas

EDIT:

I probably should mention that the machines (I'm having this same problem on two different computers) are both running Arch Linux and Arch Linux alone, although one was originally a Windows 7 and the other a dual boot of Win 7 and Ubuntu.




RESOLUTION (Thanks lhoffman):

Install the network time protocol daemon. This will allow you to sync your system time over the internet.

sudo pacman -S ntp

Once installed, run the following command:

ntpdate pool.ntp.org

This will link your computer with the time servers of the NTP Pool Project. For me my clocks fixed themselves quickly after running the command. And that was it.

After running this command and setting the system clock, run:

hwclock -systohc      (thanks Scimmia)

Otherwise the computer will mistake local time for UTC and subtract/add time based upon your timezone again upon reboot.

Last edited by douglasr (2012-12-21 21:23:11)

Offline

#2 2012-12-21 06:13:41

lhoffman
Member
Registered: 2012-12-15
Posts: 15
Website

Re: [SOLVED] System Clock Issues (Wrong UTC?)

I don't know much about the date time stuff but I am thinking you could try installing and configuring ntpd (network time protocol daemon) which may, or may not, straighten out the time zone problems you're having.

Offline

#3 2012-12-21 06:43:06

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] System Clock Issues (Wrong UTC?)

So the problem is that your RTC is set to localtime, but you've told the system that it's UTC. Use something like # timedatectl set-time "2012-10-30 18:17:16" to set the correct localtime to your system clock, then run hwclock --systohc to write the correct UTC time to the RTC.

Last edited by Scimmia (2012-12-21 06:45:16)

Offline

#4 2012-12-21 06:48:06

douglasr
Member
Registered: 2012-12-21
Posts: 19

Re: [SOLVED] System Clock Issues (Wrong UTC?)

Yes, that worked perfectly. I thank you lhoffman. I'll add the exact process as to how I fixed it into the OP.

Offline

#5 2012-12-21 06:50:15

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] System Clock Issues (Wrong UTC?)

You've just band-aided it again, though. NTPd will not write the correct UTC to the RTC when it's that far out. You still need to run hwclock --systohc to write it to the RTC.

Last edited by Scimmia (2012-12-21 06:50:31)

Offline

#6 2012-12-21 06:53:49

douglasr
Member
Registered: 2012-12-21
Posts: 19

Re: [SOLVED] System Clock Issues (Wrong UTC?)

Are you sure? When I run timedatectl status the listed UTC time is indeed correct. Though that might not mean anything, I really don't know much about any of these commands.

Offline

#7 2012-12-21 06:56:16

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] System Clock Issues (Wrong UTC?)

The UTC is correct, but I'll bet it isn't the same as what's listed for the RTC. This is the hardware clock the system will read from on boot. You currently have this set to localtime, you need to change it to UTC.

Offline

#8 2012-12-21 06:59:14

douglasr
Member
Registered: 2012-12-21
Posts: 19

Re: [SOLVED] System Clock Issues (Wrong UTC?)

Okay, fair enough. So I need to manual set the local time using timedatectl, and then rerun the hwclock --systohc --utc to fix the root of the problem?

Offline

#9 2012-12-21 07:06:01

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] System Clock Issues (Wrong UTC?)

Not exactly. The root of the problem is that your hardware clock is set to localtime. To change this, you need to update the system (software) clock, which ntpd already did for you. The timedatectl command would have just done that manually. Now that your system clock is correct, you need to write this to your hardware clock so that it is correct when you reboot. hwclock --systohc does that. If you don't run that command, the system will boot up thinking it's getting UTC from the hardware clock and will subtract 5 hours. Then, once ntpd runs, the time will skip ahead 5 hours. This will cause all kinds of issues.

Last edited by Scimmia (2012-12-21 07:07:18)

Offline

#10 2012-12-21 07:09:33

douglasr
Member
Registered: 2012-12-21
Posts: 19

Re: [SOLVED] System Clock Issues (Wrong UTC?)

Ah, okay I see. Thanks for being so patient with me, this whole thing is quite the learning experience.

Offline

#11 2012-12-21 07:45:10

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [SOLVED] System Clock Issues (Wrong UTC?)

douglasr, please mark the whole thread [SOLVED] as shown here.


To know or not to know ...
... the questions remain forever.

Offline

#12 2012-12-21 20:51:15

lhoffman
Member
Registered: 2012-12-15
Posts: 15
Website

Re: [SOLVED] System Clock Issues (Wrong UTC?)

Scimmia wrote:

Not exactly. The root of the problem is that your hardware clock is set to localtime. To change this, you need to update the system (software) clock, which ntpd already did for you. The timedatectl command would have just done that manually. Now that your system clock is correct, you need to write this to your hardware clock so that it is correct when you reboot. hwclock --systohc does that. If you don't run that command, the system will boot up thinking it's getting UTC from the hardware clock and will subtract 5 hours. Then, once ntpd runs, the time will skip ahead 5 hours. This will cause all kinds of issues.

I fixed this on my system too. Thanks for the explanation.

Offline

Board footer

Powered by FluxBB