Thursday, January 27, 2011

Change Linux timezone

Select the method as per your Linux distribution:
If you are using Fedora / RHEL / Cent OS Linux
Type the redhat-config-date command at the command line to start the time and date properties tool.

# redhat-config-date


OR type setup and select time zone configuration (good for remote ssh text based Linux server sessiob)

# setup

Now, just follow on screen instructions to change timezone

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/Calcutta):
# ln -sf /usr/share/zoneinfo/Asia/Calcutta 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 EST 2006

Use of environment variable
You can use TZ environment variable to display date and time according to your timezone:
$ export TZ=America/Los_Angeles
$ date

No comments:

Post a Comment