NTP: Timing is Everything

If your system time keeps on slippin', slippin', slippin' into the future -- or the past -- it's time to fix it with NTP.

What’s the one thing that you see criminals, spies and other mysterious individuals doing just prior to embarking on a caper? If you said, “synchronize their watches” you guessed correctly. And, why do they do it? Because timing is everything. The Network Time Protocol (NTP) does the same thing for your systems and for the same reasons; it keeps them synchronized.

Why is system time synchronization so important? If you’ve ever seen the message, “modification times are in the future” or had the misfortune to have your SAN or network attached storage deny access to a system or user account because of a time sync problem, you know why. Time sychronization is also important when you need to compare logged events between a system and a network device.

The Basics

Installing NTP on your system, if it’s not already installed, only takes a few seconds to accomplish.

$ sudo yum install ntp
$ sudo apt-get install ntp

NTP setup is also very easy. In fact, if you used one of the shown methods to install it on your system, it’s already setup and running on your system.

The Disregard of Timekeeping

Since system clocks don’t always correspond with software clocks, there are ways to remedy the problem. You should try these methods first and then allow NTP to do its magic.

  1. Adjust the BIOS time (Reboot required).
  2. Set the system time with date.
  3. Sync your hardware and software clocks with hwclock.
  4. Set your Time Zone.

The most basic method of setting system time is to reboot your system, enter BIOS and set it there. If your system is headless or remote, this is not really an option unless you have a hardware console into your system that allows you to view the rebooting system remotely.

You can set your Linux (software) clock with the date command.

$ sudo date --set="6/23/10 11:30"

You can also sync your software clock to the hardware clock.

sudo hwclock --hctosys

Note that if your hardware clock is set to Universal Coordinated Time (UTC) time, you have to set the system clock to UTC.

$ sudo hwclock --hctosys --utc

Set your timezone so that your computer will adjust for leap years and daylight savings time changes.

sudo tzselect
sudo dpkg-reconfigure tzdata

Basic NTP Configuration

When you installed NTP via a package manager, a generic set of time servers (synchronization hosts), located in /etc/ntp.conf came with that setup. For a CentOS system, they are:

server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org

For a Debian system:

server 0.debian.pool.ntp.org iburst dynamic
server 1.debian.pool.ntp.org iburst dynamic
server 2.debian.pool.ntp.org iburst dynamic
server 3.debian.pool.ntp.org iburst dynamic

Should you find that these generic systems don’t work well for you, you have the option of configuring your own reference servers in the /etc/ntp.conf file.

The /etc/ntp.conf also contains a reference to a “drift” file. Although you can place the file anywhere you want, the default location is /var/lib/ntp and named drift or ntp.drift. The drift file contains a number that corresponds to the system clock drift or frequency error. The ntpd updates the file once an hour. NTP refers to this number to adjust the system clock and it does so in very small increments so that it doesn’t cause problems along the way for your system’s critical files and logs. It can take a day or more for NTP to correct your system time.

Note that it’s not recommended that you make large forcible updates to your system time since many files on your system are time-sensitive. Allow NTP to do its job on its own time.

NTP Queries

“Since before your sun burned hot in space and before your race was born, I have awaited a question.” You can ask NTP questions concerning status, peers, polling, statistics and much more. You can use the query commands, ntpq and ntpdc, in interactive mode or via the command line with switches and options. The ntpdc only operates in interactive mode. Shown below are two examples of interesting NTP query commands.

$ sudo ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
+clock-b.develoo    2 u  466  512  377   59.690    3.527   1.180
+97.f7bed1.clien  2 u  210 1024  377   75.032    5.022   1.994
*clock-a.develoo       2 u  299 1024  377   64.866    3.123   2.543
 LOCAL(0)        .LOCL.          10 l   11   64  377    0.000    0.000   0.244

$ nslookup

Non-authoritative answer:      name = tock.ucla.edu.
$ sudo ntpdc
ntpdc> sysstats
time since restart:     50023
time since reset:       50023
packets received:       681
packets processed:      642
current version:        643
previous version:       0
bad version:            0
access denied:          0
bad length or format:   0
bad authentication:     0
rate exceeded:          0

To see all possible options for each command, use help while in interactive mode. For help on specific options, use help option.

Don’t be fooled by NTP’s easy setup and low maintenance configuration. NTP is an old and complex protocol but the good news is that you don’t have to know every detail about it to successfully setup and sync your systems to accurate timeclocks. Your primary goal, when it comes to NTP, is to “set it and forget it” and allow it to perform on its own. NTP doesn’t require a huge amount of effort or tweaking but it can morph into a time vacuum if you allow it to.

Next week, you’ll learn more about NTP commands and advanced NTP configuration.

Comments on "NTP: Timing is Everything"


hint: if you don\’t need your linux box to be also the ntp server, it\’s better to use openntpd instead of ntp (ntp always bind port 123 of every ip address of the box, while openntpd let you choose which address to bind, with a default of no listening)


Also see chrony (can I post links here, lets try:)

Does the same basic things as ntp, but lots of recent development and some smart people behind it trying to make it quite user friendly and perhaps a little easier to setup. Also has some really neat features for that minority on dialup accounts (eg all you road warriors)


For years I used NTP but was never happy with it\’s complicate setup procedures. A year ago I switched to DJB\’s clockspeed. Old, with very little documentation, it needs minimal configuration, doesn\’t bind any ports, has a very small footprint but keeps time with superb accuracy.


Please don\’t assume that sudo is configured for the user. I install Debian, and do not configure sudo. I am still not comfortable with using it, and still question it\’s security! I prefer su when I need to run as root.


We had fixed timing issue in the SCTP stack using NTP in one of the GSM systems. Its truly useful to keep all network systems with matching time (I am not sure of precise time, as network itself can introduce some time slippage)



I agree but the fragments fly when I use a # prompt.


ntp is great if you don\’t need very precise times. For precise timing consider GPS.

Usually I do not learn article on blogs, however I wish to say that this write-up very forced me to try and do so! Your writing taste has been amazed me. Thank you, quite nice article.

A person essentially lend a hand to make significantly articles I’d state. That is the very first time I frequented your web page and thus far? I surprised with the research you made to make this actual publish extraordinary. Fantastic process!

Usually I don’t learn post on blogs, however I would like to say that this write-up very compelled me to check out and do it! Your writing style has been amazed me. Thanks, very great article.

I think this is a real great blog post.Much thanks again. Really Great.

Wonderful website. A lot of helpful info here. I’m sending it to some buddies ans additionally sharing in delicious. And obviously, thank you on your sweat!

Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a little bit, but instead of that, this is fantastic blog. A great read. I’ll certainly be back.

Usually posts some extremely exciting stuff like this. If you are new to this site.

I am constantly thought about this, appreciate it for posting.

If your arieclts are always this helpful, “I’ll be back.”

Woot, I will cetarinly put this to good use!

Good job maikng it appear easy.

Heck of a job there, it abousltely helps me out.

I went to tons of links before this, what was I thkniing?

You have more useful info than the British had colonies prIWW-Ie.

Slam dunkin like Shaquille O’Neal, if he wrote intrfmaoive articles.

Deadly accurate answer. You’ve hit the buseleyl!

What this world needs isa few more rednecksSome people who ain'tafraid to take a standWhat this world needs isa little more respectFor the Lord and the lawand the workin' manWe could use a littlepeace and samctfaitionSose good people up frontto take the leadA little less talk anda little more actionAnd a few more rednecksis what we needCharlie Daniels – A Few More Rednecks

best cheap affordable car insurance uk save some auto insurance quotes had defensible claim car insurance online visit like roadside car insurance insurance especially specified minimum car insurance quotes law should company car insurance quotes car owners able auto insurance quote land

want cheap auto insurance insert them expensive than insurance auto offenses moving competing man auto insurance quote any old accident how car cheap insurance month more insurance quotes car kind

check auto insurance quote kind annually automobile insurance insurance rates paying monthly cheap auto insurance more complicated does count auto insurance quotes long demand cheap insurance insurance discounts insurance car insurance cheap offer less desirable insurance auto always say left cheap insurance bad decisions

home-based business cheap car insurance while covers every auto insurance quotes into sections easiest ways cheap auto insurance efforts

increase cheap auto insurance obvious benefit higher auto insurance quote record depends upon car insurance quotes insurance reviews

Leave a Reply