Ubuntu Linux how to set the date and time via Network Time Protocol (NTP)
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:
- Linux or FreeBSD command to display system time and date
- Linux set date and time from command prompt
- FreeBSD: Set date time and timezone
- PHP script to find and print the current date and time
- OpenBSD Set Date and Time
Discussion on This FAQ
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!


March 5th, 2007 at 11:44 am
i want java script for Disk space and disk memory and disk usage
November 20th, 2007 at 10:43 pm
Do I need to restart the cron service after editing the crontab to add ntpdate ?
November 21st, 2007 at 5:53 am
Noop, if crond is already running it will pickup new changes.