Categories

Sunday, 3 June 2012

How to change time-zone in Linux servers

Method 1: Change TimeZone Using /etc/localtime File

For this example, assume that your current timezone is UTC as shown below. You would like to change this to Pacific Time.
# date
Mon Sep 17 22:59:24 UTC 2010
On some distributions (for example, CentOS), the timezone is controlled by /etc/localtime file.
Delete the current localtime file under /etc/ directory
# cd /etc
# rm localtime
All US timezones are located under under the /usr/share/zoneinfo/US directory as shown below.
# ls /usr/share/zoneinfo/US/
Alaska          Arizona         Eastern         Hawaii          Michigan        Pacific
Aleutian        Central         East-Indiana    Indiana-Starke  Mountain        Samoa
Note: For other country timezones, browse the /usr/share/zoneinfo directory
Link the Pacific file from the above US directory to the /etc/localtime directory as shown below.
# cd /etc
# ln -s /usr/share/zoneinfo/US/Pacific localtime
Now the timezone on your Linux system is changed to US Pacific time as shown below.
# date
Mon Sep 17 23:10:14 PDT 2010

No comments:

Post a Comment

Ad