I have a dedicated web server which is running centos with xen virtualization that has centos installed on the vm. I do not have access to the parent server, I can only manipulate the vm, of which I have full control. I am having nothing but problems manipulating the date/time on the vm. The main problem now is that the time on my server is running just a little faster than "normal". I would estimate that for every 24 hours it is ahead by an extra minute. This is not good because I have scripts that need to be run at specific times and they are running minutes behind what they should. The only "fix" I have found so far is to reboot the server, but I don't want to reboot every night just to fix the time!

Here is what I have tried:

1) Setting the time manually:

root@host [~]# date
Mon May 13 06:52:22 WAKT 2013
root@host [~]# date 051306492013
Mon May 13 06:49:00 WAKT 2013
root@host [~]# date
Mon May 13 06:52:54 WAKT 2013

The date and time is reflected on the screen after the set command, but then when I run the date command a second later, it goes back to what the date "actually is". If I reboot the server, the time will be reset properly, but I am trying to avoid this reboot.

2) I was reading about setting the hardware clock which might help me, but I am unable to make any changes or do anything with it, and I believe it is because I am on a vm:

root@host [~]# /sbin/hwclock --show
Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.
root@host [~]# hwclock --systohc
Cannot access the Hardware Clock via any known method.
Use the --debug option to see the details of our search for an access method.

3) I enabled ntp, which I believe is working, but like setting the time manually, the time change doesn't "stick" until after a reboot:

root@host [~]# date
Mon May 13 06:55:36 WAKT 2013
root@host [~]# service ntpd stop
Shutting down ntpd:                                        [  OK  ]
root@host [~]# ntpdate pool.ntp.org
13 May 06:55:52 ntpdate[7146]: step time server offset -229.150633 sec
root@host [~]# service ntpd start
Starting ntpd:                                             [  OK  ]
root@host [~]# date
Mon May 13 06:56:10 WAKT 2013

Also note that I am using some weird timezone for the moment because I was trying to troubleshoot another issue I was having with the timezone being reset: https://serverfault.com/questions/494635/timezone-changing-by-itself-on-virtualized-centos-install so don't focus too much on the timezone. I just need the time to be correct for whatever timezone I am in.

Has anyone dealt with this before? I refuse to believe that there is no way to set the time on my linux box without a reboot. Any ideas or suggestions are most welcome!


If you are a running a paravirtualized xen vm you can check;


If it exists and contains 0 , try ( as root ):

echo 1 > /proc/sys/xen/independant_wallclock

Then launch your ntp server.

  • 1
    Thank you so much Olivier! This was exactly what my problem was, and although I feel stupid for not finding this myself, I am very glad it was a simple fix! I used instructions from docs.vmd.citrix.com/XenServer/4.0.1/guest/ch04s06.html to persist changes across reboots using the /etc/sysctl.conf file and now ntp is working great! – Joseph May 13 '13 at 22:19
  • You're welcome, and yes, you have to edit your sysctl.conf to make the changes persistent – Olivier S May 14 '13 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.