Setting timezone in CentOS, RHEL, Fedora

This is one of those things that I occasionally need to do, but always seem to forget.

I usually hit Google to find these commands and the process, however everyone seems to want to link to the /etc/localtime file instead of copying the file.  As this file is a main system file you need to ensure it is available at all times, so if you link accross a filesystem that becomes unavailable or corrupt, you potentially end up having issues while you try and recover your filesystems.

First step, find your time zone in /usr/share/zonedata, for me this is

/usr/share/zoneinfo/Australia/NSW

Note that your timezone may be in a subdirecory of /usr/share/zoneinfo, as mine is shown above. Now the easy bit, copy the zone file to /etc/localtime, the following command should do it..

sudo cp -a /usr/share/zoneinfo/Australia/NSW /etc/localtime

If you have trouble running the above command, you could always use the following process, bit longer but, still gets the same outcome ..

sudo cp -a /usr/share/zoneinfo/Australia/NSW /etc/localtime
cp: overwrite `/etc/localtime'? y

You should now be able to run date and make sure your timezone settings are correct.

date
Sun May 17 09:41:25 EST 2009

Next, to ensure thie stays persistent across glibc updates, set the correct timezone in the clock config file.

sudo vi /etc/sysconfig/clock

Well, that should help me when I have to go through this process again, hope it helps someone else also ..

Posted by on May 17, 2009 in Brain Purge .., Tutorials

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments are closed.