Search code examples
servervagrantvirtualboxcentos6

How to correct system clock in vagrant automatically


How to Correct Timezone

Last time, I figured out how to adjust a system clock in vagrant server. However, when I halt the vagrant and start it again, the system clock is always 9 hours late. I can adjust by using ntp command manually, but I'd like to know how to adjust the system clock automatically.

I have tried the below, but it still doesn't work. Are there any suggestions?

How to sync time on host wake-up within VirtualBox?


Solution

  • The method I use and it should not be provider specific is to add the following in my Vagrantfile

      config.vm.provision :shell, :inline => "sudo rm /etc/localtime && sudo ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime", run: "always"
    

    you would need to replace '/Europe/Paris' with the timezone you want to set