Linux

Linux Virtual Machine Time Problems

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

ntp1

 

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

ntp3

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

ntp4

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 ntp.pool.org

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.

Subscribe to VirtualizationHowto via Email 🔔

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com and has over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, Brandon has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.