5

Whenever my computer sleeps, the time in the Homestead environment goes out of sync. The time doesn't update when it wakes up, it just keeps on going from when the computer started to sleep. This forces me to destroy and then up Vagrant.

Versions:

  • Homestead 5.0.1
  • Vagrant 2.0.1
  • VirtualBox 5.2.4

I have added this to the Vagrantfile:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.provider 'virtualbox' do |vb|
       vb.customize [ "guestproperty", "set", :id, "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold", 10000 ]
    end

    config.vm.provider "virtualbox" do |vb|
       vb.customize ["modifyvm", :id, "--cableconnected1", "on"]
    end

    // More code...

How do I make the Homestead environment sync the time?

Fredrik
  • 3,027
  • 8
  • 33
  • 66
  • 1
    I have had this issue in the past as well. The only workaround I found was letting the computer put the monitor to sleep, but not the hard-drives. You also might try making sure the VirtualBox Guest Additions are up-to-date. (Placing this as a comment, and not a solution, because its only a work-around.) – mike.bronner Jan 14 '18 at 18:20
  • The VirtualBox Guest Additions are up to date. Not letting the hard drives sleep is not ideal. I will keep looking for a better solution. Thanks though. – Fredrik Jan 15 '18 at 09:45
  • So far the best solution is in this comment: https://stackoverflow.com/a/46480998/5191800 – Fredrik Feb 04 '18 at 11:46

4 Answers4

4

I came across this solution when going out of sync with s3.

edit the ntp.conf

sudo vim /etc/ntp.conf

change the servers to:

server 0.amazon.pool.ntp.org iburst
server 1.amazon.pool.ntp.org iburst
server 2.amazon.pool.ntp.org iburst
server 3.amazon.pool.ntp.org iburst

restart the ntp service

sudo service ntp restart

and you're done.

Yami Glick
  • 2,006
  • 1
  • 12
  • 6
1

restart the ntp service

$sudo service ntp restart

Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use.

Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191
0

When your computer sleeps it's using vagrant suspend command which is like hitting the pause button on time (and the universe) as far as the virtual machine is considered.

The only real fix is to manually vagrant halt your VMs before you let your computer sleep.

joepferguson
  • 1,088
  • 7
  • 18
0

You can run:

sudo service ntp stop && sudo ntpdate -s time.nist.gov && sudo service ntp start

(You may need to install ntpdate)

I've added this to after.sh so it runs on provision, but it doesn't run on wake or "up".

I'd love to find a way to do that automatically.

Hatcham
  • 330
  • 3
  • 10
  • In the latest release of Homestead, *ntpdate* is installed by default. So as of now, i run *ntpdate ntp.ubuntu.com* every time I wake up my computer. It’s not really ideal. I am thinking about making some sort of script for it. – Fredrik Mar 23 '18 at 23:55
  • 1
    ntpdate is not installed on my homestead :( – Yevgeniy Afanasyev Sep 06 '18 at 23:49