27

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

3 Answers 3

32

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

sudo dpkg-reconfigure tzdata
3
  • +1, this is definitely the right way to do it on debian systems.
    – jhauris
    Commented Jun 5, 2014 at 13:29
  • 3
    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.
    – complistic
    Commented Oct 27, 2014 at 22:31
  • yes! ppl seem to think so, but I'm using debian in a docker container.. then what?
    – superhero
    Commented Aug 17, 2015 at 13:24
22

Try this way:

$ sudo cp /usr/share/zoneinfo/Australia/Adelaide /etc/localtime
4
  • 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.
    – complistic
    Commented May 22, 2013 at 4:25
  • 2
    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" ;-)
    – jamzed
    Commented May 22, 2013 at 5:08
  • 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!
    – complistic
    Commented May 23, 2013 at 0:04
  • 3
    I think copying is wrong. What if the zoneinfo file changes? If /etc/localtime is a symlink (it is in Debian) you overwrite some other zoneinfo file.
    – XTF
    Commented Aug 3, 2017 at 13:16
-1

Set the time automatically using "Network Time Protocol". Use the following command to install ntp on debian.

$ sudo apt-get install ntp

You can find information for Greek ntp servers in http://www.pool.ntp.org/zone/gr or for Europe http://www.pool.ntp.org/zone/europe then edit the file ntp.conf

$ sudo pico /etc/ntp.conf

And replace default servers "server 0.ubuntu.pool.ntp.org" with yours

For detailed information please read the documentation https://wiki.debian.org/DateTime

1
  • 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.
    – Anthon
    Commented Apr 12, 2014 at 19:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .