2

I'm running Ubuntu Karmic on a VM with VirtualBox 3.2.8 (I need to update...) and I've just noticed that the system time on my VM is out of sync with the real world.

It seems that the time will synch properly if I reboot the machine, presumably because my laptop is being used as a surrogate BIOS and so it grabs the time from there on boot, but if I just "save" the machine when I'm not using it, the VM doesn't notice that real-time has passed while it was saved.

Is there any way that I can trigger the system to resynch its system time when it wakes up, or do I have to get used to "properly" shutting down the machine?

I run my SVN repository on the VM, so my logs are wrong for a lot of my revisions now. Not a big deal I guess, but it's definitely something I'd like fixed.

5 Answers 5

3

Have you got guest additions installed? One of the things this does is keep the system time in sync with the host.

2
  • I just tried that to be sure (can't remember if I did it on this machine before or not), and nothing happened. This is Ubuntu Karmic Server, not desktop, if that matters. Dec 5, 2010 at 19:30
  • 1
    Found this to explain installing guest additions on server Dec 5, 2010 at 19:36
4

I have the same question and found this very helpful, restart the syn daemon and the guest time will syn with host:

sudo /etc/init.d/vboxadd-service restart
0

You can use ntpd for synch time with a Time Server on internet like ntp.ubuntu.com ...

1
  • I should have been more clear. I'm looking for a way to trigger this when the VM wakes up. It might be impossible, but the only other choices I have would be to either run it as a cron job every couple minutes, or (just thought of this) write a commit hook for svn. Dec 5, 2010 at 19:12
0

xntpd should provide adequate date sync - ubuntu provides an admin interface to enable ntp functionality

1
  • 1
    Since ntpd was designed to keep machines in sync in a stable manner, it slowly corrects any time differences. So, if the time is more than 1000s (~16.6m) off, it assumes something is terribly wrong and exits. See the man page for ntpd for more information.
    – Scott Pack
    Dec 5, 2010 at 19:53
0

I am in mostly the same boat as you are. I have a VMware guest that I have running at all times inside a MacOS host on my MacBook. When I put my laptop to sleep, and wake it up, the date and time on the VMware guest is of course out of sync. I have created a small script file which calls ntpdate to sync the time on the guest. I run that script as sudo every time I access the guest after a sleep/wake cycle.

The script is as simple as this:

#!/bin/bash
/usr/sbin/nptdate time.asia.apple.com

You must log in to answer this question.

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