Date and time via NTPdate

On September 19, 2010, in Ubuntu, by mike

We don’t have to install NTP server, so we will install a  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.

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.

Installation

$ 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:

#NTPDATE
@hourly /etc/network/if-up.d/ntpdate

Save and close the file.

Easy way.

RIGHT CLICK on  desktop clock and select “set date / time” there’s an option to automatically set the time, and select the ntp.ubuntu.com servers so you don’t load the pub servers.

Leave a Reply

WordPress Blog

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Copyright © 2005-2010 Linux Server™. Use of this web site constitutes acceptance of the Linux Server™ Terms of Use and Privacy Policy. en-US Linux is a trademark registered by Linus Torvalds in the United States and other countries.