1

My /etc/localtime on my Ubuntu gives my correct timezone - EAT which is UTC +3. The date command gives the time as 21:44:58 EAT which is about the correct time (I'm not concerned about accuracy to the second in this question).

However, when I do sudo hwclock -r, it gives my time as 12:44:31 AM EAT, which is approximately three hours ahead of the correct time. I assume that the hardware clock assumes the 21:44 is in UTC.

Running the command ntpdate ntp.ubuntu.com has no effect on the hardware clock (it returns 21:44:23).

When I invoke the python interpretter and do:

import datetime
print datetime.datetime.utcnow()

It gives me 18:44:36, which is the correct UTC time (as per now).

So is it that although the hardware clock is wrong, the Operating System maintains it's own correct time? As this seems to 'go against the manual' can I safely modify the hardware clock without messing up with some other time component?

1 Answer 1

1

The operating system knows that your hardware clock is set to localtime, not UTC. This is a configurable system parameter. Linux tools that use system facilities for date/timezone management will produce the correct time. hwclock -r is guessing that your hardware clock is set to UTC, but it is guessing wrong and adding three hours when it shouldn't.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .