date/time vs hwclock driving me nuts - help~

General support questions
Post Reply
szejiekoh
Posts: 4
Joined: 2015/08/01 18:47:50

date/time vs hwclock driving me nuts - help~

Post by szejiekoh » 2015/08/01 19:11:33

Hi all,
I am on GMT+8 and i have set my hwclock clock to local. I done this specifically by doing the following

Code: Select all

rm /etc/adjtime
system-config-date -- set to my current time.
ln -s /usr/share/zoneinfo/Asia/Singapore localtime
hwclock --systohc --localtime
==================================================
Please see my current configuration before RESTART

Code: Select all

[root@sjoam2 ~]# date
Sun Aug  2 03:02:08 SGT 2015

[root@sjoam2 ~]# hwclock --debug
hwclock from util-linux-ng 2.17.2
Using /dev interface to clock.
Last drift adjustment done at 1438455666 seconds after 1969
Last calibration done at 1438455666 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2015/08/02 03:02:11
Hw clock time : 2015/08/02 03:02:11 = 1438455731 seconds since 1969
Sun 02 Aug 2015 03:02:11 AM SGT  -0.391210 seconds

[root@sjoam2 ~]# cat /etc/adjtime 
0.000000 1438455666 0.000000
1438455666
LOCAL
All good and ready to go (so i proceed with a restart) and the date is added +8 as if the hwclock is in GMT which is not~ (the hwclock --debug is still showing the correct date/time) though.

Code: Select all

[root@sjoam2 ~]# date
Sun Aug  2 11:05:39 SGT 2015  [b][color=#FF0000] -- why +8 hours again when i already specify that the hwclock is in localtime~?[/color][/b]


[root@sjoam2 ~]# hwclock --debug
hwclock from util-linux-ng 2.17.2
Using /dev interface to clock.
Last drift adjustment done at 1438455666 seconds after 1969
Last calibration done at 1438455666 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
...got clock tick
Time read from Hardware Clock: 2015/08/02 03:05:38
Hw clock time : 2015/08/02 03:05:38 = 1438455938 seconds since 1969
Sun 02 Aug 2015 03:05:38 AM SGT  -0.500720 seconds [b][color=#FF0000] -- well this is still the correct time~~[/color][/b]

i have tried the hwclock --systohc --utc, but still the same. hwclock --debug will show the correct time in UTC and the added 8 hours in GMT+8, but date will add another 8 hours on top of that. (total of 16 hours added)

Hope some gurus shed some light on what's wrong~

P.S. -- please do not ask me to use ntp. I have wasted 2 days on this and i really wanna get it fix

Regards,
Noob

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: date/time vs hwclock driving me nuts - help~

Post by TrevorH » 2015/08/01 20:09:00

Run rpm -V tzdata and if you see any output then run yum reinstall tzdata to reinstall it and correct the problems.

Next, on CentOS 6, don't symlink /etc/localtime to your intended zone file, rm the symlink and physically copy the file you want to /etc/localtime.

Post the output from uname -a and also if you are running on a real machine or a VM of some description. If you're not sure then installing the virt-what package and running the virt-what command might tell you more - if it returns nothing then it's likely you're on a real machine.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

szejiekoh
Posts: 4
Joined: 2015/08/01 18:47:50

Re: date/time vs hwclock driving me nuts - help~

Post by szejiekoh » 2015/08/02 05:40:41

Hi TrevorH,

Thanks for the reply.
As instructed, i have done a rpm -V tzdata but found no output.

I have also removed the softlink localtime and copy the yum update /usr/share/zoneinfo/Asia/Singapore to localtime in /etc

Code: Select all

cp /usr/share/zoneinfo/Asia/Singapore localtime 
chmod 777 localtime

Below is my uname -a

Code: Select all

[root@sjoam2 etc]# uname -a
Linux sjoam2.oracleszejie.com 2.6.32-504.23.4.el6.x86_64 #1 SMP Tue Jun 9 20:57:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Yes i am on vmware on ESXI 5.5. But the funny thing is i have created another new VM, load centos ISO on it, and there is no problem with the hwclock and time with the same configurations.

Regards,
Noob

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: date/time vs hwclock driving me nuts - help~

Post by TrevorH » 2015/08/02 11:08:50

Permissions on /etc/localtime should not be 777 but 644. However that won't affect your time, merely whether your users can change timezones behind your back without root access!

I suspect that the problem comes from VMWare. If you have the vmware guest tools installed then it has an option to keep the clock in sync with the host. That option was in the config file on the host when I last used vmware about 10 years ago!
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

szejiekoh
Posts: 4
Joined: 2015/08/01 18:47:50

Re: date/time vs hwclock driving me nuts - help~

Post by szejiekoh » 2015/08/04 16:09:53

Hi Trevor,

Just want to update you and hope this can be of help to anyone in the same plight.

Yes. this is cause by time synchronisation by vmtool. Removing the vmtool or setting the host clock correctly will solved the problem.

I choose not to remove vmtool but set the host clock to correctly; Howver, i can't stop to think -> what clock will the guest actually follow now, the host clock or the hwclock of the guest ?

Regards,
Noob

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: date/time vs hwclock driving me nuts - help~

Post by gerald_clark » 2015/08/04 17:57:25

Virtual machines don't have a hardware clock.
They have pseudo hardware based on the host's clock.

szejiekoh
Posts: 4
Joined: 2015/08/01 18:47:50

Re: date/time vs hwclock driving me nuts - help~

Post by szejiekoh » 2015/08/05 16:49:40

gerald_clark wrote:Virtual machines don't have a hardware clock.
They have pseudo hardware based on the host's clock.
Hi Gerald,

Yeap, What i mean is the so call "hardware" clock of the guest machine that you can access via BIOS when you try to startup the guest machine.

And it is not based/set accordingly to the host clock. Before i adjusted my host's system and hardware clock, the guest OS "hardware/pseudo" clock in the BIOs is of a different timing with the host's

Regards,
Noob

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: date/time vs hwclock driving me nuts - help~

Post by gerald_clark » 2015/08/05 18:41:27

If it wasn't based on the host clock it would be some random datetime.

Post Reply