Ubuntu clock is wrong and I can't change it (running as VirtualBox Guest under OSX)
Solution 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.
Solution 2
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.
Related videos on Youtube
Ludo
Updated on September 18, 2022Comments
-
Ludo over 1 year
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?
-
Daniel R Hicks almost 12 yearsMy guess would be that the timezone on the host got changed to GMT and its clock set to local time or some such.
-
Vladimir S. over 10 yearsPlease check my solution at link. You have to change some details, in my case I have Windows host.
-
-
Ludo over 12 yearsHi. 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.
-
new123456 over 12 years@Ludo I also hear that one can put
export TZ="Europe/London"
into your .bashrc/.zshrc. Try that. -
Ludo over 12 yearsHi, thanks, after adding that to my .bashrc "date" now shows the correct time! However, the gnome clock is still wrong. Cheers :)