6
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 seems to work. In changing the date on this computer server running as VM is not working.

Our messages log show messages like these

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 seems 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.
2
  • 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. Nov 26, 2012 at 10:36
  • @AndreyVoitenkov it is a VM. I will have a look and see what I can find out.
    – nelaaro
    Nov 26, 2012 at 10:45

2 Answers 2

3

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

1
  • Hit this issue on an old CentOS 5 running on Rackspace. Hugely helpful. Thanks.
    – rmarscher
    Aug 25, 2015 at 17:59
1

For Mageia users and his parents (RedHat, Mandrake, Mandriva) we will install ntp and ntp-client with the urpmi command:

# urpmi ntp ntp-client

Then we will start the service and enable it to start automatically on reboot.

# systemctl start chronyd.service
# systemctl enable chronyd.service

Now we check if timedatectl has NTP based network time synchronization enabled:

# timedatectl status
Local time: Wed 2016-12-07 13:39:04 EET
Universal time: Wed 2016-12-07 11:39:04 UTC
RTC time: Wed 2016-12-07 11:38:56
Timezone: Europe/Bucharest (EET, +0200)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2016-10-30 03:59:59 EEST
Sun 2016-10-30 03:00:00 EET
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2017-03-26 02:59:59 EET
Sun 2017-03-26 04:00:00 EEST
# date
Wed Dec  7 13:39:11 EET 2016
# timedatectl set-timezone Europe/Bucharest
# date
Wed Dec  7 13:39:48 EET 2016
#

Without enabling NTP synchronization timezone/time won't change.

Now we will enable NTP based network time synchronization and set the new timezone:

# timedatectl set-ntp 1
# timedatectl set-timezone Europe/Bucharest
# date
Wed Dec  7 10:43:33 EET 2016
# timedatectl status
Local time: Wed 2016-12-07 10:43:59 EET
Universal time: Wed 2016-12-07 08:43:59 UTC
RTC time: Wed 2016-12-07 08:43:59
Timezone: Europe/Bucharest (EET, +0200)
NTP enabled: yes  
NTP synchronized: yes
RTC in local TZ: no
DST active: no
Last DST change: DST ended at
Sun 2016-10-30 03:59:59 EEST
Sun 2016-10-30 03:00:00 EET
Next DST change: DST begins (the clock jumps one hour forward) at
Sun 2017-03-26 02:59:59 EET
Sun 2017-03-26 04:00:00 EEST
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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