Friday, 5 July 2013

Change timezone in Xen VPS


The file /etc/localtime is the one which holds information of server’s timezone.

For changing the timezone you should point it to the correct zone file by creating a soft link.

From following commands below we are changing the current timezone to IST:

Firstly move the current localtime file as backup.

#mv /etc/localtime /etc/localtime.bak
Now from /usr/share/zoneinfo/ you can find the preferred timezone. Once you found the timezone file, crate a soft link   to  /etc/localtime. Eg: For IST

#ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
You are done!! You can find the timezone changed. But if you reboot the vps the settings will get reverted back. So once finishing the steps above, do the following. 

 Run following command

echo 1 > /proc/sys/xen/independent_wallclock

Now installed ntp in the vps.

# yum install ntp 
# chkconfig ntpd on

 Synchronize the system clock with 0.pool.ntp.org server:

# ntpdate pool.ntp.org

Start NTP

# /etc/init.d/ntpd start


Now edit /etc/rc.local with your favorite editor and put the following lines there.

# vi  /etc/rc.local

service ntpd stop
echo 1 > /proc/sys/xen/independent_wallclock
ntpdate pool.ntp.org
service ntpd start


You would now get correct timezone and correct time every time you reboot your Xen VPS.



No comments:

Post a Comment