Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
date +%T --set="12:19:06"
12:19:06
date
Mon Nov 26 12:37:32 SAST 2012

date 112613232012
Mon Nov 26 13:23:00 SAST 2012
date
Mon Nov 26 13:42:27 SAST 2012

I have tried many different forms of this command but nothing seams to work. In changing the date on this computer server running as VM is not working.

Our messages log show messages like thise

ntpd[3496]: time correction of -1098 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.

Our server is now about 20 minutes out.

It seams like our server has not been updating the time correctly for a few days.

Nov 22 19:29:23 hostname ntpd[1818]: time reset -998.577519 s
Nov 22 19:32:34 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10
Nov 22 19:33:39 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1
Nov 22 19:52:30 hostname ntpd[1818]: time reset -998.992426 s
Nov 22 19:55:47 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10
Nov 22 19:56:53 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1
Nov 22 20:13:04 hostname ntpd[1818]: time reset -999.374412 s
Nov 22 20:16:40 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10
Nov 22 20:17:44 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1
Nov 22 20:32:02 hostname ntpd[1818]: time reset -999.716832 s
Nov 22 20:35:28 hostname ntpd[1818]: synchronized to LOCAL(0), stratum 10
Nov 22 20:36:16 hostname ntpd[1818]: synchronized to 41.134.20.28, stratum 1
Nov 22 20:56:39 hostname ntpd[1818]: time correction of -1000 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.
share|improve this question
    
Are you running this linux on bare metal? Or it is a kind of guest in virtualization environment. If the latter is true, guest date/time might be synchronized to host. There must be an option to prevent such behaviour. –  Andrey Voitenkov Nov 26 '12 at 10:36
    
@AndreyVoitenkov it is a VM. I will have a look and see what I can find out. –  nelaar Nov 26 '12 at 10:45

1 Answer 1

up vote 0 down vote accepted

http://www.linuxforum.com/threads/2154-Linux-ntp-time-Offset-on-Xen-VM-incorrect

After a lot of searching I found that by default, the VM's clocks are synchronized to the HOST clock running on the control domain, and cannot be independently changed. This was surprising to me because NTP was still configured and appeared able to synchronize the clocks.

add the following line to your /etc/sysctl.conf file

# Allow the VM to update it's own clock, and do not use the DOM host clock.
xen.independent_wallclock=1

then restart the network service

/etc/init.d/network restart #for redhat, centos, fedora
/etc/init.d/networking restart #debian, ubuntu

now you can set the date with date -s ...

Here is a link to the official xen docs
Here is a link to the ntp docs

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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