0

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.

2
  • what virtualization technology are you using?
    – jeff
    Aug 13, 2009 at 18:30
  • virtualbox (hmmm 15 characters minimum ;)
    – Phil
    Aug 13, 2009 at 22:02

4 Answers 4

4
+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.

2

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

1
  • 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.
    – user17642
    Aug 24, 2009 at 16:49
0

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.
0
man 8 hwclock

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

*/1 * * * *  hwclock --hctosys
1
  • but hardware clock will be guest 'hardware' clock, i guess? so not what i'm looking for?
    – Phil
    Aug 27, 2009 at 18:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .