Changing timezone on Debian keeps Local Time in UTC

87,844

Solution 1

Try this way:

$ sudo cp /usr/share/zoneinfo/Australia/Adelaide /etc/localtime

Solution 2

I think the best way to achieve this, is by executing:

sudo dpkg-reconfigure tzdata
Share:
87,844
complistic
Author by

complistic

Updated on September 18, 2022

Comments

  • complistic
    complistic over 1 year

    I'm trying to get programs to log in local time for my own sanity.

    I have updated my timezone with:

     dpkg-reconfigure tzdata
    

    But the result of that command is:

    Current default time zone: 'Australia/Adelaide'
    Local time is now:      Mon May 20 03:09:52 UTC 2013.
    Universal Time is now:  Mon May 20 03:09:52 UTC 2013.
    

    Notice the UTC in Local time

    Any reason why this may be?

    I have done a lot of Googling but my problem seems different to all of them :(

    Here are some more details:

    # cat /etc/timezone
    Australia/Adelaide
    
    # date
    Mon May 20 03:41:06 UTC 2013
    
    # export TZ='Australia/Adelaide'; date
    Mon May 20 13:16:11 CST 2013
    

    Setting export TZ='Australia/Adelaide'; in my /etc/profile makes date work by default in a bash session but does not change the system log date (after restarting the service)

    Edit:

    # ls -l /etc/localtime
    lrwxrwxrwx 1 root root 20 May 10 14:48 /etc/localtime -> /usr/share/zoneinfo/
    
    # ls /etc/localtime/
    Adelaide    Chile    GMT        Japan      PST8PDT    Universal
    Africa      Cuba     GMT+0      Kwajalein  Pacific    W-SU
    America     EET      GMT-0      Libya      Poland     WET
    Antarctica  EST      GMT0       MET        Portugal   Zulu
    Arctic      EST5EDT  Greenwich  MST        ROC        iso3166.tab
    Asia        Egypt    HST        MST7MDT    ROK        localtime
    Atlantic    Eire     Hongkong   Mexico     Singapore  localtime.dpkg-new
    Australia   Etc      Iceland    Mideast    SystemV    posix
    Brazil      Europe   Indian     NZ         Turkey     posixrules
    CET         Factory  Iran       NZ-CHAT    UCT        right
    CST6CDT     GB       Israel     Navajo     US         zone.tab
    Canada      GB-Eire  Jamaica    PRC        UTC
    

    Answer:

    Worked it out thanks to jamzed. for some reason I had /etc/localtime as a symlink... the IT Guy here set up the server using Turnkey 12 so maybe that was the problem.

    # mv /etc/localtime /etc/localtime.old
    # cp /usr/share/zoneinfo/Australia/Adelaide /etc/localtime
    # date
    Thu May 23 09:36:17 CST 2013
    
  • Admin
    Admin almost 11 years
    cp /usr/share/zoneinfo/Australia/Adelaide /etc/localtime dit not change anything for me :( local time is still UTC, I have added what ls -l /etc/localtime says also.
  • Admin
    Admin almost 11 years
    Why did you create symlink there? You need to copy a one file... Fix it by removing symlink "rm /etc/localtime" and do cp as I wrote "cp /usr/share/zoneinfo/Australia/Adelaide /etc/localtime" ;-)
  • complistic
    complistic almost 11 years
    symlink was there by default.. maybe a turnkey thing or something. mv /etc/localtime /etc/localtime.old cp /usr/share/zoneinfo/Australia/Adelaide /etc/localtime fixed the problem :) Thank you!
  • Anthon
    Anthon about 10 years
    It is better to provide the steps here, and use the link as a reference for further details. That way your answer does not lose all of it value when the link becomes invalid.
  • jhauris
    jhauris almost 10 years
    +1, this is definitely the right way to do it on debian systems.
  • complistic
    complistic over 9 years
    Yep, dpkg-reconfigure tzdata was the first thing I tried. It didn’t work for me because /etc/localtime was a symlink for some reason. After fixing that both ways would change the timezone correctly.
  • superhero
    superhero almost 9 years
    yes! ppl seem to think so, but I'm using debian in a docker container.. then what?