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

share|improve this question
add comment

5 Answers

up vote 0 down vote accepted

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

share|improve this answer
    
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. –  AgentConundrum Dec 5 '10 at 19:30
    
Found this to explain installing guest additions on server –  AgentConundrum Dec 5 '10 at 19:36
add comment

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
share|improve this answer
add comment

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

share|improve this answer
    
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. –  AgentConundrum Dec 5 '10 at 19:12
add comment

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

share|improve this answer
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 '10 at 19:53
add comment

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
share|improve this answer
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.