Jaime Frutos Morales's blog

02/09/2010

How to synchonize your Ubuntu 10.04 desktop with a NTP server

Filed under: SysAdmin, Ubuntu — acidborg @ 12:21

Description: On my previous post, I explained how to install and configure a NTP server on your local network. Now I’m going to explain how to synchronize an Ubuntu 10.04 computer with your local NTP server.

Installation: apt-get install ntpdate

Configuration:

  1. Create the file /etc/cron.d/ntpdate.cron with the following content (modifying “your-ntp-server” with the name or IP address of your NTP server):
    15 */1 * * * root /usr/sbin/ntpdate your-ntp-server &> /dev/null
  2. This will synchronize your computer’s clock with the NTP server every hour. If you want to increase the synchronization period, increase the “/1”. For example: Use 15 */6 * * * root /usr/sbin/ntpdate your-ntp-server &> /dev/null to synchronize your computer’s clock every 6 hours.
  3. Set the proper owner and permissions for the created file: chmod 600 /etc/cron.d/ntpdate.cron && chown root:root /etc/cron.d/ntpdate.cron
Advertisements

4 Comments

  1. This is a HORRIBLE suggestion if you run any apps that are sensitive to jumps in the system time. It’s MUCH better to use the ntpd service.

    Additionally, the NTP project STRONGLY discourages people from using your suggested method because it hammers the public NTP servers at the top of the hour.

    Far better is to simply ‘apt-get install ntp’ and configure your /etc/ntp.conf to point to an NTP pool server (or leave it Canonical’s default NTP server). It doesn’t require any effort on the part of the desktop user and is easier than your suggested method.

    Seriously, it’s been known that using ntpdate with cron is a bad idea for nearly 10 years.

    http://lists.debian.org/debian-user/2002/12/msg04091.html

    Comment by AK — 02/09/2010 @ 17:21

    • Thanks for the feedback AK.

      The main purpose of this article is to synchronize an Ubuntu 10.04 computer with a local NTP server (you are right, it’s not a good idea to use this synchronization method against a public NTP server. I have updated the post). I’ve chosen to use this way instead of using ntpd because I neither want to open listening ports nor add new firewall rules on clients. A local NTP server can easily handle local users’ time synchronization requests every hour.

      Comment by acidborg — 02/09/2010 @ 21:41

  2. Even worse, after re-reading your article, the crontab example is also horribly wrong. The syntax you supplied runs ntpdate every minute of the hour on even numbered hours.

    A properly configured ntp will only check roughly 3 time per hour and spaced out such that it imposes low loads on the time server. A mere 72 time checks per day.

    This method runs the ntpdate 720 times per day!

    This is a very good way to get your public IP blacklisted from a time server.

    Comment by AK — 02/09/2010 @ 21:05

    • You’re right. That was a typo (updated). Thanks for your feedback!

      Comment by acidborg — 02/09/2010 @ 21:47


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Create a free website or blog at WordPress.com.

%d bloggers like this: