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.

Phil
  • 1,969
  • 6
  • 29
  • 33

4 Answers4

4

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

Kristaps
  • 2,985
  • 17
  • 22
  • 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. –  Aug 24 '09 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.
OtherDevOpsGene
  • 2,532
  • 20
  • 16
0
man 8 hwclock

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

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