About Linux FAQ

Browse More FAQs:

Ubuntu Linux how to set the date and time via Network Time Protocol (NTP)

Posted by Vivek Gite [Last updated: December 26, 2006]

Q. How do I setup Ubuntu Linux system time using Network Time Protocol (NTP)? Do I need to install ntp server?

A. No you don't have to install NTP server. All you have to do is install simple client called ntpdate. ntpdate sets the local date and time by polling the Network Time Protocol (NTP) server(s) given as the server arguments to determine the correct time. It must be run as root on the local host.

A number of samples are obtained from each of the servers specified and a subset of the NTP clock filter and selection algorithms are applied to select the best of these. Note that the accuracy and reliability of ntpdate depends on the number of servers, the number of polls each time it is run and the interval between runs.

Please note that ntpdate will decline to set the date if an NTP server daemon (ntpd) is running on the same host. When running ntpdate on a regular basis from cron as an alternative to running a daemon, doing so once every hour or two will result in precise enough timekeeping to avoid stepping the clock.

Install ntpdate client

$ sudo apt-get install ntpdate

ntpdate will automatically run when your network interface get activated by system (i.e. while booting Ubuntu Linux sever/desktop system) . Ubuntu Linux stores script at /etc/network/if-up.d/ntpdate location.

If you wish to just run script again just type command:
$ sudo /etc/network/if-up.d/ntpdate
OR
$ sudo ntpdate pool.ntp.org

Install as cronjob

To avoid stepping the clock you must run ntpdate every 1 or 2 hours using cronjob:
crontab -e
Now add hourly job:
#Setup NTPDATE
@hourly /etc/network/if-up.d/ntpdate

Save and close the file.

Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

Related Other Helpful FAQs:

Discussion on This FAQ

  1. Ashok.S Says:

    i want java script for Disk space and disk memory and disk usage

  2. Rupert Says:

    Do I need to restart the cron service after editing the crontab to add ntpdate ?

  3. vivek Says:

    Noop, if crond is already running it will pickup new changes.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.