June 2014 1 post
Changing the time zone in CentOS
Friday, June 6, 2014
Here's how to change the time zone in CentOS. This should work on both CentOS 5 and 6.
First, determine the correct timezone. You can do this using tzselect
(which just outputs some text and doesn't save anything), or by looking in /usr/share/zoneinfo
for the right file. I'm on Pacific time, so for me it would be America/Los_Angeles.
Now, back up your existing time zone file:
# mv /etc/localtime /etc/localtime.bak
Then symlink the desired zoneinfo file to localtime:
# ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
Now if you run date
, the appropriate time zone should be displayed. There is one more step though. Open up the file /etc/sysconfig/clock
and edit it to reflect the appropriate zone. For example:
ZONE="America/Los_Angeles"
Without this change, /etc/localtime
will get overwritten and will revert to the previous time zone after yum or rpm updates tzdata.