1

REAL TIME : 4:06 PM

router@router:~$ sudo hwclock

*Sat 09 Jan 2016 04:06:55* [ 4pm is the actual time]

router@router:~$ date

*Sat Jan 9 1:06:44 NPT 2016* [but ubuntu shows time as 1pm]

but as soon as i connect my internet :

router@router:~$ date

*Sat Jan 9 16:06:44 NPT 2016* [1pm corrects to 4pm only when i connect internet.... else won;t]

how to sync time time with hwclock???

6
  • Is the correct time 1:06 or 4:06?
    – Mitch
    Jan 9, 2016 at 10:37
  • 16:06 is the same as 4:06 PM.
    – Mitch
    Jan 9, 2016 at 12:19
  • itsnot 16:06 .. its 1:06 the incorrect time... let me make it more clear.. suppose 4pm is current time... hwclock also shows 4pm .... but date via terminal shows 1pm. Jan 9, 2016 at 12:25
  • But in your question you say:"but as soon as i connect my internet : date Sat Jan 9 16:06:44 NPT 2016". If that is not correct, please edit your question with the correct time.
    – Mitch
    Jan 9, 2016 at 12:28
  • ya thats right ... the time sync to normal time.... but suppose i don;t use internet at all.... the time will continue from 1 pm and suppose after 34 min ... the time will show 1:34 pm.... not the actual time which would be 4:34pm Jan 9, 2016 at 12:29

1 Answer 1

0

The hwclock does not know about timezones and daylight saving, and different OS's deal with it differently. Because the old DOS did not know any other clock then the RTC/hwclock it was set in local time. I think this is still the default of all current Windows systems. The default in (most?) Linux based systems is to expect the hwclock to be set to UTC.

Because systems can boot several different OS's Linux can not demand the hwclock to be in UTC. Therefor it has a parameter to adjust time from hwclock to kernelclock / UTC in case of the hardwareclock is running localtime. Programs normally want to show you localtime so there is a different parameter to adjust for timezone and daylight saving.

It seems like in your system there is a discrepancy between your hwclock, UTC correction and timezone / daylight saving.

You can see what your hwclock is running with timedatectl, it will show you all data you want:

Local time: za 2016-01-09 17:46:05 CET
Universal time: za 2016-01-09 16:46:05 UTC
RTC time: za 2016-01-09 16:46:05
Time zone: Europe/Amsterdam (CET, +0100)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

If I change my hwclock to:

Local time: za 2016-01-09 17:52:10 CET
Universal time: za 2016-01-09 16:52:10 UTC
RTC time: za 2016-01-09 17:52:10
Time zone: Europe/Amsterdam (CET, +0100)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no

and restart*, the hwclock will be used to set the initial kerneltime. Hwclock will give me then 17:52 after restart while date will give me a wrong localtime 18:52. After communication with an ntp server it adjust kernel time and you will see the correct time with date again.

* Some Linux distributions nowadays set the hwclock from systemtime when shutting down, so the hwclock might be adjusted to UTC after restart.

You must log in to answer this question.

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