Linux Virtual Machine Time Problems

Recently in working with a pair of Linux virtual machines, we ran into a problem with the system time on both boxes.  The symptoms of the problem were this – you could set the time manually using the date command.  After having set the time and checked for accuracy, a day later the machine would be anywhere from 4 to 8 hours ahead.  Multiple combinations of time synchronization were tried both setting the time via NTP and without NTP.  However, the problem we found was not with the client VM but with the host ESXi box.

What we found was the host ESXi boxes times were off.  They had not been set to pull from any time source initially.   NTP was active, just no servers were defined.  The hosts were off around 2 hours either fast or slow.  For most of us having the correct timestamps is critical to business operation and to ensure accuracy of data.  If you are using a VMware environment, it is critical that you make sure your ESX or ESXi hosts have the correct time as this WILL adversely affect your client VMs.

Configuring VMWare host time

Within vCenter Server, you can check your time settings for a host by clicking on the host, maneuvering to the “Configuration” tab and then over on the left side of the configuration pane, there is the Software box where you will find the Time Configuration menu option.

After clicking the “Time Configuration” option you will see the following….click the Properties option



After clicking Properties, you will be brought to the NTP configuration screens


Click the NTP Settings option above to configure your NTP server(s)


Be sure to click the “Restart NTP service to apply changes” option to make sure the settings are applied

Configuring Client VMs

Configuring linux time manually via the date command:

  • date 111609062011 translates to November 16, 9:06 A.M 2011
  • Checking the state of the NTP service – service ntpd status
  • To check your NTP configuration….edit the file located at /etc/ntp.conf
  • NTPQ command can be used to query NTP servers and check your configuration also
  • After getting to the NTPQ prompt, typing opeer will display peers that are being used to sync NTP time, along with delay, offset, and dispersion times
  • Forcing a manual sync with NTP servers – ntpdate

Final Thoughts

Please keep in mind that in a virtual environment both the time of your hosts as well as the client vms themselves have an impact on the time settings within Linux.  If there is a skew of time between them, you will find yourself in the situation we mentioned in the outset where time is being set all over the place without any rhyme or reason.

Back to top button