19 April 2014

Change The RHEL/CentOS Linux Time Zone

After Linux server has been installed and you noticed that time zone has not been set correctly, here is how to do it:

1. Check the current time zone:

# cat /etc/sysconfig/clock
ZONE="America/New_York"

# date
Thu Jul  9 06:46:14 EDT 2013


2. You can find the list of available time zones under /usr/share/zoneinfo:

# ls /usr/share/zoneinfo
Africa      Atlantic   Chile    Eire     Factory  GMT-0      Iceland      Jamaica    Mexico   NZ        posix       ROC        Universal  zone.tab
America     Australia  CST6CDT  EST      GB       GMT+0      Indian       Japan      Mideast  NZ-CHAT   posixrules  ROK        US         Zulu
Antarctica  Brazil     Cuba     EST5EDT  GB-Eire  Greenwich  Iran         Kwajalein  MST      Pacific   PRC         Singapore  UTC
Arctic      Canada     EET      Etc      GMT      Hongkong   iso3166.tab  Libya      MST7MDT  Poland    PST8PDT     Turkey     WET
Asia        CET        Egypt    Europe   GMT0     HST        Israel       MET        Navajo   Portugal  right       UCT        W-SU


# ls /usr/share/zoneinfo/Europe/
Amsterdam  Berlin      Chisinau    Helsinki     Kiev        Madrid     Moscow     Prague      Sarajevo    Tallinn   Vatican    Zagreb
Andorra    Bratislava  Copenhagen  Isle_of_Man  Lisbon      Malta      Nicosia    Riga        Simferopol  Tirane    Vienna     Zaporozhye
Athens     Brussels    Dublin      Istanbul     Ljubljana   Mariehamn  Oslo       Rome        Skopje      Tiraspol  Vilnius    Zurich
Belfast    Bucharest   Gibraltar   Jersey       London      Minsk      Paris      Samara      Sofia       Uzhgorod  Volgograd
Belgrade   Budapest    Guernsey    Kaliningrad  Luxembourg  Monaco     Podgorica  San_Marino  Stockholm   Vaduz     Warsaw


3. Change it to your desired time zone:

# vi /etc/sysconfig/clock

ZONE="Europe/Berlin"


4. Create a backup of current localtime file and create a new one as a symbolic link to the zone file:

# mv /etc/localtime /etc/localtime.old

# ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime

# ls -l /etc/localtime*


5. Time zone has been changed now:

# cat /etc/sysconfig/clock
ZONE="Europe/Berlin"

# date
Thu Jul  9 12:59:39 CEST 2013

But you can reboot the server in order for other applications running on the server use the new time zone. 





No comments:

Post a Comment