Linux – Ubuntu clock is wrong and I can’t change it (running as VirtualBox Guest under OSX)

datelinuxtimeUbuntuvirtualbox

I have a strange problem with my Ubuntu Natty virtual machine running under VirtualBox on OSX.

One day last week, my clock on the top bar in Gnome stopped displaying the correct time (I'm not running Unity). I'm on GMT, so right now it should be 9:31, but it's showing 3:31, so I think it's something to do with TimeZones.

If I go into the date and time applet, the time is initially wrong but after a second sets itself to the correct GMT Time. The timezone is correclty set as London and it makes no difference if I unlock and set it again or select manual or automatic from internet time.

From a bash prompt, the "date" command shows: "Tue Sep 20 03:33:35 CDT 2011".

If I run "sudo dpkg-reconfigure tzdata" I am correctly set as London. Upon exiting the commnand I'm shown the correct London time, but then typing "date" again shows the CDT time again.

:~/$ date
Tue Sep 20 03:33:35 CDT 2011

:~/$ sudo dpkg-reconfigure tzdata
Current default time zone: 'Europe/London'
Local time is now:      Tue Sep 20 09:34:22 BST 2011.
Universal Time is now:  Tue Sep 20 08:34:22 UTC 2011.

:~/$ date
Tue Sep 20 03:34:26 CDT 2011

The clock is correct in OSX. This has been working fine for a month or two – I think it stopped working after an update last week. Any ideas?

Best Answer

I had a similar issue with ArchLinux guest in VirtualBox host. When I use TIMEZONE="Africa/Johannesburg" or TIMEZONE="Asia/Bahrain" in my rc.conf file, the output of date is correct but when I use TIMEZONE="/Etc/GMT+2" or "/Etc/GMT+3" (corresponding to aforementioned timezones) then the VBoxService sets time 6 hours to early.

My hardware clock time always remains correct (sudo hwclock --show) and setting system time from hardware clock (sudo hwclock --hctosys) sets system time correctly until VBoxService runs timesync again and output of date is 6 hours too early.

To summarize; using timezones from /usr/share/zoneinfo// seems to work but other zoneinfos might not work, I don't know why this is.

Related Question