How to Fix VirtualBox Time Synchonization Problems

I’ve been running VirtualBox for a couple of years now but lately I’ve been having problems with the time synchronization between my 32-bit Windows XP guest and my 64-bit Ubuntu Linux 10.04 host in VirtualBox 3.2.12. Frequently, I’ve noticed that the guest’s clock has been as much as 15 or even 20 minutes slower than the host’s clock.

This magnitude of clock drift can be problematic for many types of programs and use cases. For example, some of my appointment reminders have appeared 15 minutes too late, nearly causing me to miss appointments!

After trolling through the VirtualBox forums for several minutes, I noticed that several other users have had the same VirtualBox slow time problem. Multiple solutions were suggested but many of them didn’t seem to work. At times like this, it’s helpful to go back to the basics and read the “fine” manual (RTFM). In particular, I found this section to be very helpful: Tuning the Guest Additions time synchronization parameters.

There are a number of tunable parameters for time synchronization but I found --timesync-set-threshold to be the most useful for fixing the time drift. Here’s the description from the manual:

–timesync-set-threshold

The absolute drift threshold, given as milliseconds where to start setting the time instead of trying to smoothly adjust it. The default is 20 minutes.

Remarkably, the default is a whopping 20 minutes! No wonder my reminders have been popping up so late.

To fix the time sync clock drift, you just need to set --timesync-set-threshold to a smaller value. How small? That’s up to you. It really depends on how much you can afford your clock to be off. For me, I decided to use 15000 milliseconds (15 seconds). For you, maybe it will be 60000 milliseconds (1 minute). I’m not sure if there are any side-effects if you set the threshold too low.

To set the threshold to 15 seconds, run the following command on the VirtualBox host:

VBoxManage guestproperty set “the name of your guest VM” “/VirtualBox/GuestAdd/VBoxService/–timesync-set-threshold” 15000

Don’t forget to replace “the name of your guest VM” with the name of your VM. Note that I did not have to run the command as sudo but your mileage may vary.

If the above command doesn’t seem to work, try power cycling your VirtualBox guest. That did the trick for me.

If you ever want to see the current value of --timesync-set-threshold simply run this command on the VirtualBox host:

VBoxManage guestproperty get “the name of your guest VM” “/VirtualBox/GuestAdd/VBoxService/–timesync-set-threshold”

If you try my technique to fix a slow clock in VirtualBox, please leave a comment here to let me know if it worked for you.

Be Sociable, Share!

    9 comments to How to Fix VirtualBox Time Synchonization Problems

    • I had the same problem on

      Host: Ubuntu 10.10 64 bit
      Guest: WinXP 32 bit
      VirtualBox: 3.2.12 r68302

      Solution works fine and no problems with 1000ms sync.

      Many thanks!

    • Jorn Skorstad

      Same problem as you, I could actually see how the clock slowed down in Guest OS Windows XP. Not nice for the software depending on UTC time +/- 1 second!

      My host: Ubuntu 10.10 32-bit. Your solution worked like a charm. Thanks!

    • Stuart

      Host: Ubuntu 10.10 64 bit
      Guest: WinXP 32 bit
      VirtualBox: 3.2.12 r68302

      Restarted guest.

      No change after applying your solution :-(

    • Stuart

      OK. My mistake. After examining the xml file I noticed that the entry for timesync-set-threshold was incorrect. I had copied the command from this page into a terminal – the double quote characters are wrong and the “–” is “-”. Should have read the VirtualBox doco a *bit* closer…

      I have set the –timesync-set-threshold parameter to 1000 ms.

      Clock still drifts by up to 10000 ms before being corrected. Which is the default interval for the –timesync-interval parameter. I will set this down to 1000 ms and see what happens. I expect this will resolve the clock drift issue – I’ll report back if this causes problems in other areas…

    • Andrew

      On Windows you can edit the VirtualBox service in the registry and append

      –timesync-interval 1000 –timesync-set-threshold 1000

    • Kooorrg

      I think you misunderstood the meaning of “–-timesync-set-threshold”. If the time sync service detects a difference between the host time and the guest time, and if this difference is less than “–timesync-set-threshold” it will try to make the guest clock slightly faster or slightly slower for a while in order to catch up smoothly with the host. Some programs don’t like abrupt time transitions at all, especially if they are backward. But if the difference goes above “–timesync-set-threshold” then it will set the time right away.

      Now if you’re not pausing the VM for long periods of time and if the timesync service is actually running and cannot manage to keep the time synchronized, it means that there is another issue… Your fix is just hiding the problem.

    • David

      Worked like a charm on a difficult xp pro client!

      Host: Ubuntu Lucid 10.04.3 64-bit.

    • I’d had the same problem — time in Linux guest was around 20 min behind the host’s clock after 4 days of the guest being up and running.

      I discovered that in my case (VirtualBox 4.1.12r77245 on 64-bit Debian squeeze) –timesync-interval value had not been set up at all! So I reckon time sync had never been done for this guest.

      I set timesync interval to 10 seconds and it seems to fix the problem — zero time drift so far (a few hours).

      $ VBoxManage guestproperty get rqtracker “/VirtualBox/GuestAdd/VBoxService/–timesync-interval”
      No value set!
      $ VBoxManage guestproperty set rqtracker “/VirtualBox/GuestAdd/VBoxService/–timesync-interval” 10000
      $ VBoxManage guestproperty get rqtracker “/VirtualBox/GuestAdd/VBoxService/–timesync-interval”
      Value: 10000
      $

    • Once again: don’t forget to use double dash in the command. The webpage shows only single dash-es.

    Leave a Reply

     

     

     

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>