Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running wp on lamp install in virtual machine. I frequently pause it, save snapshots, etc. Date and time aren't correct because of this and i think i noticed weird behavior of plugins that use cron. How do i fix my time and plugins? Maybe i should get time from external location so it would be correct even though i regularly pause my machine?

It's Debian Lenny guest on other linux host. I'm using virtualbox.

share|improve this question
    
what virtualization technology are you using? –  jeff Aug 13 '09 at 18:30
    
virtualbox (hmmm 15 characters minimum ;) –  Phil Aug 13 '09 at 22:02
add comment

4 Answers

up vote 4 down vote accepted
+100

What you need is Time Synchronization, which is a feature of the Guest Additions in Virtual Box. Looks like it wasn't installed. From the Virtualbox manual:

Time synchronization With the Guest Additions installed, VirtualBox can ensure that the guest’s system time is better synchronized. This fixes the problem that an operating system normally expects to have 100% of a computer’s time for itself without interference, which is no longer the case when your VM runs together with your host operating system and possibly other applications on your host. As a result, your guest operating system’s timing will soon be off significantly. The Guest Additions will re-synchronize the time regularly.

Install instructions here.

share|improve this answer
add comment

To syncronise time, use NTP (Network time protocol).

Firstly, sync time with

sudo ntpdate ntp.ubuntu.com

Then, install ntpd sudo apt-get install ntp

share|improve this answer
2  
This isn't really what you want. You want your host machine synchronized with NTP and you want your guest synched to your host. Otherwise, they guest time will be jumping all over the place. –  emgee Aug 24 '09 at 16:49
add comment

VMs don't always play well with ntp.

If you are using VMware, install the VMware tools. Then, there is a setting in the .vmx file called time.syncTime that should be set to TRUE (although the time seems to be staying sync'd since I install VMware Tools even set to the default FALSE).

Here are some other VMware settings: (from http://www.vmware.com/pdf/vmware_timekeeping.pdf):

  • tools.syncTime If set to TRUE, the clock syncs periodically.
  • time.synchronize.continue If set to TRUE, the clock syncs after taking a snapshot.
  • time.synchronize.restore If set to TRUE, the clock syncs after reverting to a snapshot.
  • time.synchronize.resume.disk If set to TRUE, the clock syncs after resuming from suspend and after migrating to a new host using the VMware VMotion feature.
  • time.synchronize.shrink If set to TRUE, the clock syncs after defragmenting a virtual disk.
  • time.synchronize.tools.startup If set to TRUE, the clock syncs when the tools daemon starts up, normally while the guest operating system is booting.
share|improve this answer
add comment
man 8 hwclock

or add this to root's crontab in the virtual machine

*/1 * * * *  hwclock --hctosys
share|improve this answer
    
but hardware clock will be guest 'hardware' clock, i guess? so not what i'm looking for? –  Phil Aug 27 '09 at 18:04
add comment

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.