Search This Blog

Tuesday, September 10, 2013

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

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.


Create a symlink to file localtime:

# ln -sf /usr/share/zoneinfo/EST /etc/localtime

Eg: # ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime

date -s "10/15/2005 09:40:00 EDT"

date -s "10/15/2005 09:40:00"
/sbin/hwclock --systohc


Edit the /etc/sysconfig/clock text file so that it looks like this:

ZONE="America/Denver"
UTC=true
ARC=false

Of course, this assumes that your hardware clock is running UTC time...

3. Delete the following file: /etc/localtime

4. Create a new soft link for /etc/localtime. Here is an example of step 3 and step 4:

# cd /etc
# ls -al localtime
lrwxrwxrwx 1 root root 39 Mar 28 07:00 localtime -> /usr/share/zoneinfo/America/Los_Angeles

# rm /etc/localtime

# ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
# ls -al localtime
lrwxrwxrwx 1 root root 34 Mar 28 08:59 localtime -> /usr/share/zoneinfo/America/Denver

# date
Fri Mar 28 09:00:04 MST 2003


date; date > ~/date."bak-`/bin/date`"; cat /etc/sysconfig/clock; ls -l /etc/localtime

NTP Configuration and Usage:

No comments: