Chang centOS Time-zone and Update Time Using ntp

I needed to change the timezone of the server from AST to GMT

First check your current Time zone with command date


[root@sms ~]# date
Tue Mar 18 16:15:04 AST 2014

Now decide what time zone you want. You can see your timezones

[root@sms ~]# cd /usr/share/zoneinfo/
[root@sms zoneinfo]# ls -la
total 308
drwxr-xr-x. 21 root root 4096 Dec 23 2012 .
drwxr-xr-x. 245 root root 12288 Feb 27 2013 ..
drwxr-xr-x. 2 root root 4096 Dec 23 2012 Africa
drwxr-xr-x. 6 root root 4096 Dec 23 2012 America
drwxr-xr-x. 2 root root 4096 Dec 23 2012 Antarctica
drwxr-xr-x. 2 root root 4096 Dec 23 2012 Arctic
drwxr-xr-x. 2 root root 4096 Dec 23 2012 Asia
drwxr-xr-x. 2 root root 4096 Dec 23 2012 Atlantic
drwxr-xr-x. 2 root root 4096 Dec 23 2012 Australia
drwxr-xr-x. 2 root root 4096 Dec 23 2012 Brazil
....
......
.......

now create the link of the time zone you need. Here is example

ln -sf /usr/share/zoneinfo/REGION/TIMEZONE /etc/localtime

i need to set server time to GMT so here is what i did


[root@sms ~]# ln -sf /usr/share/zoneinfo/GMT /etc/localtime

restart your crontab

[root@sms ~]# /sbin/service crond restart

Update Time Using ntp

Install ntp

[root@sms ~]# yum install ntp

edit the config file

[root@sms ~]# nano /etc/ntp.conf

look for default server, which look some thing like following.

#server 0.centos.pool.ntp.org
#server 1.centos.pool.ntp.org
#server 2.centos.pool.ntp.org

You can use the default servers of can use ntp servers, it is your choice.

#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst

start or restart ntp

[root@sms ~]# /etc/init.d/ntpd restart

turn on ntp service at startup.

[root@sms ~]# chkconfig ntpd on

finally update the date time and time-zone

[root@sms ~]# ntpdate pool.ntp.org
[root@sms ~]# /etc/init.d/ntpd restart

test the service and query ntp

[root@sms ~]#  ntpq -p

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.