2009/08/04

Timezone configuration on SLES Linux

Having some trouble with clock drift with 2 SLES 9 SuSE linux boxes. Turns out vmware and the hwclock settings I chose during setup of the OS have been conspiring to put a long drift on my two systems. Fixing it is somewhat simple. Setting it up right the first time is obviously the best solution. To remedy:

Do this stuff to get your time figured out and fixed to where you want from an OS perspective:

Totally stolen from: http://www.planetmy.com/blog/how-to-configure-timezone-on-sles-linux/

The following tutorial will guide you How to configure TIMEZONE on SLES Linux.

Basically you can configure Linux timezone using two methods which is using command or YaST.

Note: use timezone “GMT+0“ for an example below.

For YaST timezone setup, it’s pretty simple. Login to terminal and type:

#YasT Setup

yast timezone

Select Global, select GMT+0
Hardware clock Set To: Localtime
Click Accept.

For command line setup, you’re require to know these 2 files /etc/localtime and /etc/sysconfig/clock.

#Backup existing file

mv /etc/localtime /etc/localtime.old

cp /etc/sysconfig/clock /etc/sysconfig/clock.old

#Edit configuration files

ln -s /usr/share/zoneinfo/GMT+0 /etc/localtimevi /etc/sysconfig/clock

TIMEZONE=GMT+0

HWCLOCK="--localtime"

Bear in mind, you can have different timezone setup for individual or global user by using user profile in your system. For an example,

#Edit configuration file

vi /etc/profile or ~username/.bash_profile
export TZ=/usr/share/zoneinfo/Asia/Kuala_Lumpur

Export “TZ” will overwrite /etc/sysconfig/clock or /etc/localtime setup. Mean that I can use Kuala Lumpur as my separate time zone for particular user in the same system eventhrough my primary timezone setup is GMT+0.

NTP setup
#Edit NTP configuration file

vi /etc/ntp.confserver 0.europe.pool.ntp.org

server 1.europe.pool.ntp.org
server 2.europe.pool.ntp.org
server 3.europe.pool.ntp.org
server your.ntp.server

#Restart NTP Server

rcxntpd xntpd restart

Hardware Clock

#showing hardware clock

hwclock --show

#set the system time from the hardware clock

hwclock --hctosys

#set the hardware clock from the system time

hwclock --systohc

Done!


After doing this verify your clock isn't drifting crazy by using ntpq and lpeers to figure out your clock delay offset and jitter numbers. Seems to work well, saves us some trouble in the future maybe it'll help someone else out of course.

Failing that this thread on the vmware community website illustrates the "clock=pit" option.

URL TO FOLLOW

It refers to this PDF:
http://www.vmware.com/pdf/vmware_timekeeping.pdf

No comments: