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

1

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?

Ludo

Posted 2011-09-20T08:47:08.007

Reputation: 193

My guess would be that the timezone on the host got changed to GMT and its clock set to local time or some such. – Daniel R Hicks – 2012-05-27T11:26:52.873

Please check my solution at link. You have to change some details, in my case I have Windows host.

– Vladimir S. – 2013-08-13T01:56:48.267

Answers

1

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.

flyman

Posted 2011-09-20T08:47:08.007

Reputation: 11

1

I had the exact same issue on my regular Ubuntu install. The reason turned out to be that I had installed sontek's dotfiles. In a .profile, the TZ variable was explicitly set to America/Chicago. Removing this entry fixed the problem.

What lead me to the answer was this question, and new123456's comment.

bohrax

Posted 2011-09-20T08:47:08.007

Reputation: 111

0

In order to change your timezone, run the following command in the shell:

$ sudo "ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime"

That command assumes that your hardware (BIOS) clock is GMT. You can scour /usr/share/zoneinfo for a better option.

new123456

Posted 2011-09-20T08:47:08.007

Reputation: 3 707

Hi. Thanks!

I've run: sudo ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

and /etc/localtime is now indeed a link to /usr/share/zoneinfo/Europe/London.

However, "date" still shows CDT and my clock is still wrong. Any other idea? Thanks. – Ludo – 2011-09-20T10:50:45.277

@Ludo I also hear that one can put export TZ="Europe/London" into your .bashrc/.zshrc. Try that. – new123456 – 2011-09-20T20:00:20.260

Hi, thanks, after adding that to my .bashrc "date" now shows the correct time! However, the gnome clock is still wrong. Cheers :) – Ludo – 2011-09-26T14:32:05.807