ntp - Ubuntu 7.x

 

ntp - Ubuntu 7.x

 

+

Search Tips   |   Advanced Search

 

Time Synchronisation with NTP

NTP is a TCP/IP protocol for synchronising time over a network. A client requests the current time from a server, and uses it to set the system clock.

Tier one NTP servers connect to atomic clocks (often via GPS).

Tier two and three servers spread the load of handling requests across the internet.

Ubuntu has two ways of automatically setting the time...

  1. ntpdate

    Ubuntu comes with ntpdate as standard, and will run it once at boot time to set up your time according to Ubuntu's NTP server.

    To set the time more often, set cron to run ntpdate every day.

    Create a file...

    /etc/cron.daily/ntpdate

    ...containing...

    ntpdate ntp.ubuntu.com

    Make the file executable...

    sudo chmod 755 /etc/cron.daily/ntpdate
  2. ntpd

    The ntpd daemon calculates the drift of the system clock and continuously adjusts it. The cost is a little processing power and memory, but for a modern server this is negligible.

    To set up ntpd:

    sudo apt-get install ntp-simple

 

Changing Time Servers

In both cases above, the system will use Ubuntu's NTP server at...

ntp.ubuntu.com

To use several servers, increasing accuracy and resilience, use time servers that are geographically closer to you. To do this for ntpdate, change the contents of...

/etc/cron.daily/ntpdate

...to...

ntpdate ntp.ubuntu.com pool.ntp.org

...and for ntpd edit...

/etc/ntp.conf

...to include additional server lines...

server ntp.ubuntu.com
server pool.ntp.org

The server pool.ntp.org uses round-robin DNS to return an NTP server from a pool, spreading the load between several different servers. There are pools for different regions. For instance, if you are in New Zealand, use...

nz.pool.ntp.org

You can also Google for NTP servers in your region, and add these to your configuration. To test that a server works, type...

sudo ntpdate ntp.server.name

 

  Home