Syncing Linux time with time server (NTP)

The following is how you set your linux time server to continuously sync with the world time server (NTP server) to have the most accurate timing for your server.

The config works on my fedora server and should work on Redhat based linux… other distros may be similar but different path..

firstly link your local zone info to the /etc/localtime in this case our server is ‘Asia/Singapore’. The zone info in fedora is located at ’/usr/share/zoneinfo’.
Do a sym link from zone info u want to the /etc/localtime

 
ln -sf /usr/share/zoneinfo/Asia/Singapore /etc/localtime
 

Open the file ’/etc/sysconfig/clock’ set the UTC accordingly, in my case i set it as UTC=true

after its done you need to set the hardware clock by executing the command:

 
/sbin/hwclock --systohc
 

check if the system time is correct now by executing the ‘date’ command.

Next to sync the server automatically you need to have ntp package installed… use ‘yum install ntp’ to install easily.

Once its installed, edit the file ’/etc/ntp.conf’
add the line:

 
server time.asia.apple.com
 

you can add as many ntp server in the file.
Once done just do a first sync :

 
[root@passionstreams root]# ntpdate time.asia.apple.com
Looking for host time.asia.apple.com and service ntp
host found : sng-ntp.asia.apple.com
20 Jan 12:37:53 ntpdate[17605]: adjust time server 17.82.254.7 offset -0.139597 sec
 

as you see the server is adjusting its time with a 0.139597 sec delay.

thats it…

Tags: , , ,
Linux & Open Source, System Administration |

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)