Welcome

Friday, May 8, 2009

change or setup the timezone on Linux Server

Set timezone using /etc/localtime configuration file [any Linux distro]

Often /etc/localtime is a symlink to the file localtime or to the correct time zone file in the system time zone directory.
Generic procedure to change timezone



Change directory to /etc
# cd /etc

Create a symlink to file localtime:
# ln -sf /usr/share/zoneinfo/EST localtime

OR some distro use /usr/share/zoneinfo/dirname/zonefile format (Red hat and friends)
# ln -sf /usr/share/zoneinfo/EST localtime

OR if you want to set up it to IST (Asia/Jakarta):
# ln -sf /usr/share/zoneinfo/Asia/Jakarta localtime

Please mote that in above example you need to use directory structure i.e. if you want to set the timezone to Calcutta (India) which is located in the Asia directory you will then have to setup using as above.

Use date command to verify that your timezone is changed:
$ date
Output:

Tue Aug 27 14:46:08 WIT 2006

Use of environment variable

You can use TZ environment variable to display date and time according to your timezone:
$ export TZ=Asia/Jakarta
$ date

Sample Output:

Thu Aug 27 11:10:08 WIT 2006

No comments: