Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to change server time on a Vagrant box on Virtualbox
#!/bin/bash
# Log in into the box
vagrant ssh
# VirtualBox syncs host time with guest, so we need to shut off VBox Guest Additions first
sudo service vboxadd-service stop
# Now you can set any date and time
sudo date -s "2020-10-01 10:25:00"
# Want to sync again with host? Restart Guest Additions
# Anyway on the next Vagrant up it will sync again regardless
sudo service vboxadd-service start
@tabacitu

This comment has been minimized.

Copy link

@tabacitu tabacitu commented May 14, 2018

Thank you!

@devbhuwan

This comment has been minimized.

Copy link

@devbhuwan devbhuwan commented May 16, 2018

Thank you! This is what I am looking for.

@chilio

This comment has been minimized.

Copy link

@chilio chilio commented May 22, 2018

I'm on windows and using vagrant with homestead.
In my case it is not working.
This is what I've tried:

  1. ssh to vagrant machine
  2. stop vboxadd-service and I can confirm it is inactive now...
  3. modify date with sudo date -s "2020-10-01 10:25:00"
  4. calling date gives me actual date...

Any other ideas (Vagrant v2.1, Homestead v7, VBox v5.2.12) ?

@Kyiv85

This comment has been minimized.

Copy link

@Kyiv85 Kyiv85 commented May 24, 2018

I have the same problem... But in my case the actual time is incorrect, I want to fix it and NOTHING! :-/

[root@localhost ~]# service vboxadd-service stop
vboxadd-service.sh: Stopping VirtualBox Guest Addition service.
vboxadd-service.sh: VirtualBox Guest Addition service failed to stop.
[root@localhost ~]# service vboxadd-service stop
[root@localhost ~]# date -s "2018-05-24 12:12:50"
Thu May 24 12:12:50 UTC 2018
[root@localhost ~]# service vboxadd-service start
vboxadd-service.sh: Starting VirtualBox Guest Addition service.
[root@localhost ~]# date
Thu May 24 15:12:44 UTC 2018

@LinLin-3radical

This comment has been minimized.

Copy link

@LinLin-3radical LinLin-3radical commented Oct 12, 2018

thanks, it works like a charm

@poncianodiego

This comment has been minimized.

Copy link

@poncianodiego poncianodiego commented Feb 19, 2019

sudo service vboxadd-service stop and sudo service vboxadd-service start is not needed in laravel homstead

@wseyler

This comment has been minimized.

Copy link

@wseyler wseyler commented Apr 9, 2019

Thanks... Was a lifesaver for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.