如何在VirtualBox中同步主机唤醒时间? [英] How to sync time on host wake-up within VirtualBox?

查看:201
本文介绍了如何在VirtualBox中同步主机唤醒时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VirtualBox在Vagrant中运行基于Ubuntu 12.04的盒子。到目前为止,一切都很好-除了一件事:

I am running an Ubuntu 12.04-based box inside of Vagrant using VirtualBox. So far, everything is fine - except for one thing:

让我们假设虚拟机正在运行。然后,主机进入待机模式。再次唤醒虚拟机后,该虚拟机仍在运行,但是其内部时钟继续运行,在主机关闭时停止在该位置。因此,这基本上意味着:将主机休眠15分钟,再次将其唤醒,然后VM的内部时钟延迟15分钟。

Let's assume that the VM is running. Then, the host goes to standby-mode. After waking it up again, the VM is still running, but its internal clock continues where it stopped when the host went down. So this basically means: Put the host to sleep for 15 minutes, wake it up again, then the VM's internal clock is 15 minutes late.

如何解决此问题(出于明显的原因,不能手动设置时间;-))?每当主机系统更改其状态时,是否可以在Vagrant VM中运行脚本?

How can I fix this (setting the time manually is not an option for obvious reasons ;-))? Is there a way to run a script inside of a Vagrant VM whenever the host system changes its state?

我已经读过文档,默认情况下,VirtualBox Guest Additions每10秒与主机同步一次时间。显然这没有发生,但是我找不到任何禁用它的地方。有什么想法吗?

I've read in the documentation that by default the VirtualBox Guest Additions sync the time with the host every 10 seconds. Apparently this is not happening, but I can not find any place where it is disabled. So any ideas?

PS:已安装来宾添加项,并与使用的VirtualBox版本匹配。

PS: The Guest Additions are installed and match the version of VirtualBox being used.

推荐答案

文档在此处缺少一些细节。

The documentation lacks some details here.

VirtualBox每10秒钟执行一次操作只是稍作调整(大约为0.005秒)。仅当时间差达到阈值(默认为20分钟)时,才会执行真实重新同步。

What VirtualBox does every 10 seconds is just slight adjustement (something like 0.005 seconds). Only when the time difference reaches a threshold (20 minutes by default) a "real" resync is done.

您可以使用以下命令将阈值降低(即减少至10秒)以下命令:

You can reduce the thresold (i.e. to 10 seconds) with the following command:

VBoxManage guestproperty set <vm-name> "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold" 10000

这篇关于如何在VirtualBox中同步主机唤醒时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆