Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is the output of my date command:

[root@r1304 ~]# date
Wed Apr 18 15:43:28 GST 2012

I want to change the default system timezone to Asia/Dubai. I've fallowed a tutorial and did fallowing:

ln -sf /usr/share/zoneinfo/Asia/Dubai /etc/localtime

But with no effect. Seems that this is done differently in CentOS 6. How do I change the timezone?

share|improve this question
    
This shouldn't be so complex... –  ewwhite Nov 25 '12 at 0:21

4 Answers 4

up vote 17 down vote accepted

It's look like that CentOS 6.2 have't any hwclock line in it /etc/rc.sysinit, so change /etc/sysconfig/clock will not work.

try tzselect or use ln -s /usr/share/zoneinfo/xxxx /etc/localtime

share|improve this answer
1  
Thanks, that worked for me. My solution was rm /etc/localtime && ln -s /usr/share/zoneinfo/America/New_York /etc/localtime. –  Banjer Feb 3 '13 at 21:00
    
Thanks to having mentioned {{tzselect}} command :) –  Giorgio Vespucci Jul 11 at 13:25
    
What's better to use for this - ln or cp? –  XåpplI'-I0llwlg'I - Sep 9 at 12:28
    
In this case, using a symlink is probably better than copying the file –  JDS Oct 21 at 15:13

Edit the file /etc/sysconfig/clock to suit your needs.

share|improve this answer
1  
That's not a complete solution. You need to set the timezone offset. –  ewwhite Nov 25 '12 at 0:47
2  
although this is not a complete answer, this step is quite essential. without updating sysconfig/clock (something we did not do when changing timezones)... running certain yum updates / installs (unsure which ones), will cause the timezone to revert to the one listed in sysconfig/clock... regardless of what /etc/localtime was replaced with. so yea... make sure to update sysconfig/clock to make your timezone change stick. –  anonymous-one Mar 19 '13 at 13:07
    
Yum update can cause a disaster in case /etc/localtime and /etc/sysconfig/clock point to two different timezones. Updating mysql for instance can cause a nice time shift in all the dates. –  elbuild Oct 19 at 17:40

Simple tutorial, try this..

[root@dlp ~]# vi /etc/sysconfig/clock

# change to your location
ZONE="Asia/Tokyo"

[root@dlp ~]# source /etc/sysconfig/clock # reload
# copy your timezone file under the "/usr/share/zoneinfo" like follows
[root@dlp ~]# cp -p /usr/share/zoneinfo
share|improve this answer
    
this worked for me, other options didn't –  Bokw Sep 18 '13 at 7:20
    
If these instructions work at all, it'd be good to explain why ... I see no reason why sourcing /etc/sysconfig/clock would have any effect on the subsequent cp program (or indeed, on any subsequent program) –  offby1 Aug 25 at 22:37

First use tzselect to find out which is your timezone. The final output of tzselect will be something like:

Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
America/New_York

The very last line is the name of your zoneinfo file.

Now create a symlink from /etc/localtime to the correct zoneinfo file, e.g.:

ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime 

The -f flag is needed to overwrite the existing /etc/localtime.

Note: running tzselect won't touch anything on your system, it will just output some text. The "or" in the answer by caojun is misleading. You must use tzselect AND ln. From the tzselect manpage: "[tzselect] outputs the resulting timezone description to standard output".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.