Set up Linux (Ubuntu) server to synchronise clock with NTP time server

ntupdate

ntupdate comes built in into Ubintu server. To manually adjust server time run:
sudo ntpdate ntp.ubuntu.com
You can choose another ntp server instead of  ntp.ubuntu.com

ntpd

To automatically keep server time up to date use ntp.

Install ntpd:
sudo apt-get install ntp

ntpd should start working immediately without any additional configuration. However you obviously can adjust settings if you wish.

Configuration

ntpd configuration file is located in /etc/ntp.conf

Default server is server ntp.ubuntu.com
To use additional servers just add them bellow server ntp.ubuntu.com. e.g.
# You do need to talk to an NTP server or two (or three).
server ntp.ubuntu.com
server pool.ntp.org


To enable logging uncomment:
statsdir /var/log/ntpstats/
logs will be placed in /var/log/ntpstats/

Useful commands

Reastart ntp
sudo /etc/init.d/ntp restart
Stop ntp
sudo /etc/init.d/ntp stop
Start ntp
sudo /etc/init.d/ntp start

List peers and status
ntpq -p

Check in ntpd process is running
ps ax | grep ntp

Ubuntu Server 10.10


Comments  

Gene
# Gene 2011-08-09 12:47
Thanks!

Newsletter

Subscribe to receive occasional updates on new posts.
Your email will not be used for any other purpose and you can unsubscribe at any time.
Please wait