I'm running Ubuntu 12.04 LTS under vmWare. When I restart a suspended image, the system clock doesn't detect that the system time is out of date. In the Time and Date settings dialog, I've selected "Set time automatically from the Internet", but no amount of clicking on the two options (the other is "Set time manually") makes the System actually "check the internet" and use the correct time. Is there a way that I can force the local system (running under vmWare) to change the time to the "internet time"?
-
Do you have the vmware tools installed? The tools have the ability to run commands on suspend/resume. – jsbillings Sep 21 '13 at 03:07
-
@jsbillings yes I do, but I was hoping for a simple ubuntu UI action I could take. I had also expected this to happen automatically. – Chris Gerken Sep 21 '13 at 03:41
2 Answers
Install an NTP service on the virtual machine:
sudo apt-get install ntp
That way the virtual machine (assuming it has internet access) will set its time from a remote NTP server.
If this is already installed, check that the service is running:
sudo service ntp status
If it is not, start it:
sudo service ntp start
Finally, you can force it to get the time from the server with
sudo ntpdate 1.debian.pool.ntp.org

- 242,166
-
1That's not so simple: the guest doesn't know that it's been suspended and resumed. Furthermore, installing NTP on a VMware guest is actually a bad idea, at least in certain configurations (which I've encountered, but I don't know how widely applicable my one experience is), because the guest and the host fight to compensate the drift and the guest clock goes haywire as a result. – Gilles 'SO- stop being evil' Sep 21 '13 at 01:05
Setting time from the Internet is done via NTP. There are two methods:
ntpdate
makes one query to retrieve the current time from a server and sets the computer's clock to that time.- An ntp daemon makes regular query to one or more servers and typically maintains the local clock with an accuracy of a few milliseconds or better relative to the time server(s).
NTP refuses to follow sudden jumps of the time server: it assumes that if there is a large discrepancy between the local clock and the server (the maximum is 20 min if I remember correctly), this must be due to a network problem or a misconfiguration (e.g. wrong timezone).
When you restart a suspended image, the system clock should detect this (the virtual processor receives a timer interrupt). If this isn't working for you, you should investigate this further, because setting the time from the Internet won't solve your problem. Your problem description sounds like a bug in VMware or in the Linux kernel.
When a suspended image resumes, the processor only sees a time jump, it doesn't get the information that the virtual machine was suspended. So there is no way to run a program (such as ntpdate
) on resuming. (Unless there's a way to do that through the VMware tools, I don't know.)
VMware (at least ESX) has its own timekeeping software. As far as I know, running time synchronization software both on the host and on the guest tends to go badly because each side compensates for the same drift and you end up with huge fluctuations. Make sure that the host is keeping the right time and don't run any time synchronization software in the guest.

- 829,060