1

I copied /usr/share/zoneinfo/Asia/Kolkata to /etc/localtime. I also tried editing ZONE in /etc/sysconfig/clock but my default timezone is still CEST and not IST.

I already checked to make sure that a TZ variable isn't overriding it.

I've already googled it and found http://www.redhat.com/advice/tips/timezone.html and http://kezhong.wordpress.com/2010/03/08/change-timezone-on-centos-5-4/ but it didn't help.

I'm out of ideas. What am I doing wrong?

[root@dhroid ~]$ cat /etc/sysconfig/clock 
ZONE="Asia/Kolkata"
UTC=false
ARC=false
[root@dhroid ~]$ ls -al /etc/localtime 
lrwxrwxrwx 1 root root 32 Jul 19 16:10 /etc/localtime -> /usr/share/zoneinfo/Asia/Kolkata
[root@dhroid ~]$ env | grep TZ
[root@dhroid ~]$ date
Tue Jul 19 16:11:52 CEST 2011
[root@dhroid ~]$ 
1
  • what about the daemons such as crond or syslog? when i change /etc/localtime or /etc/sysconfig/clock, the date and time showed in console changes really, but the logs for crontabs and messages mantains the past timestamp... it is necessary a reboot ...
    – user217354
    Apr 23, 2014 at 6:21

5 Answers 5

7

I have fixed the problem. There was nothing wrong with what I did. Everything was right the whole time. The issue was with the tzdata package, which was corrupted. As soon as I reinstalled the package from yum with yum reinstall tzdata, it worked!

1
  • All that you had to do is just run tzdata-update utility. This copies the correct zonefile to /etc/localtime. Jul 4, 2013 at 15:15
2

after saving the changes to the file: '/etc/sysconfig/clock' a reboot is required for the changes in the timezone to take affect. Did you reboot your box after that ?

18
  • No, I haven't rebooted. But what about the /etc/localtime. When I worked with other systems (Fedora and Debian), I only needed to change /etc/localtime. I didn't need to do anything else.
    – dhroid
    Jul 19, 2011 at 14:20
  • # ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime Exit from all sessions you are currently logged in and try rebooting your box. #date command will then show a updated time zone. Jul 19, 2011 at 14:23
  • 2
    I'm not rebooting the system. There has to be a better solution. Other distros don't require a reboot for timezone changes.
    – dhroid
    Jul 19, 2011 at 14:29
  • Which distro are you using ? If it is a RedHat / Fedora / CentOS, then I am confident that a reboot is required for the changes to take place because there is something called hardware clock which should also sync with system timings and that will happen only after a reboot. That's what I suggest. Jul 19, 2011 at 14:34
  • It is CentOS. Well my Fedora server didn't require a reboot and the change was applied immediately. The only difference is the CentOS is a VMware system and Fedora one is OpenVZ.
    – dhroid
    Jul 19, 2011 at 14:39
2

Found an answer that worked for me here (Ubuntu 14.04+): Timezone setting in Linux [closed]

$ sudo timedatectl set-timezone Etc/UTC

I double checked with a reboot, it persists. Hope this helps someone :)

0

i'm not 100% certain, but i believe that if you have /etc/sysconfig/clock configured with

UTC=false

then you aren't going to be able to dynamically change the timezone.

all of my machines are set with UTC true, and the local timezone as america/los_angeles. if i relink /etc/localtime to a different timezone, it's reflected in the 'date' command immediately.

if your system clock isn't locked to UTC, then the system doesn't know how to interpret a changed timezone, since they're all relative to UTC. only a reboot will reset its brain.

edit: so i think the bottom line is that until you've configured /etc/sysconfig/clock to UTC=true and rebooted (and reset your bios clock to utc) then you're stuck with that reboot.

2
  • I have asked my host company's technical support to
    – dhroid
    Jul 20, 2011 at 5:55
  • Turns out even support weren't able to find out what the problem is. I've tried with both settings, UTC set to true and false, and neither makes a difference. Support has suggested I reinstall the OS. I'm gonna do that as a last resort but I really want to find out why this is happening in the first place. I've not heard of anyone with this issue before.
    – dhroid
    Jul 20, 2011 at 12:50
0

Ran into this on Ubuntu recently. dhroid's answer gave me the hint I needed. Creating a new answer since the specific step was different on Ubuntu/Debian. Typically I have been setting timezone with:

sudo mv /etc/localtime{,.bak}
sudo ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Strangely that wasn't working so I tried to reconfigure tzdata:

sudo dpkg-reconfigure tzdata

Got this strange result:

Current default time zone: 'America/Los_Angeles'
Local time is now:      Wed Jul  6 20:10:37 UTC 2016.

Reinstalling tzdata fixed it: (apt-get install replaces existing package with latest)

sudo apt-get install tzdata

date
etc. PDT 2016

You must log in to answer this question.

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