32

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 followed a tutorial and did this:

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?

peterh
  • 5,017
Temnovit
  • 1,147
  • 7
  • 19
  • 27

5 Answers5

45

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

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

frmbelz
  • 109
caojun
  • 466
9

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".

Luca Gibelli
  • 2,811
4

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

pkhamre
  • 6,400
2

One should restart rsyslogd after changing the timezone so that the new timezone is reflected in the logs.

Do this with: service rsyslog restart

1

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
rails_id
  • 119