How to Check NTP Sync in Linux

Cover Image for How to Check NTP Sync in Linux

Keeping accurate time on your Linux devices is important for many applications and system functions. The Network Time Protocol (NTP) allows systems to synchronize time over a network, using servers as a reference. But how can you check if NTP is properly syncing your Linux device?

There are a few straightforward ways to do so.

Step 1: Check the NTP Service Status

The first step is checking if the NTP service itself is running on your Linux distribution. The service name may vary between "ntpd", "chronyd", or "systemd-timesyncd" depending on the distro.

To check the status, run:

systemctl status ntpd (or substitute chronyd/timesyncd)

This will show the active status of the service. If it's not running, you'll need to start it with:

systemctl start ntpd

Once running, NTP will periodically sync time in the background.

Step 2: Look at Date/Time Values

Now that NTP is active, we can check if it's successfully updating the system time using a few date/time commands:

timedatectl status

This prints out the current date, time, timezone, and information from the RTC (hardware clock). Check that the values look correct.

The "NTP service" line shows whether NTP is active and syncing. The "NTP synchronized" flag will say "yes" if connected to NTP servers.

Step 3: Compare NTP Server Time Offset

A more definitive check is comparing your system time directly to the NTP server time. The goal is to have a minimal offset between them.

Run ntpstat to see sync values:

ntpstat

This connects to NTP servers and displays important info:

  • offset - the difference between local and server time

  • delay - round trip communication time

The offset value indicates your synchronization accuracy. Well below 100ms (0.1 seconds) is excellent. Higher latency links may show larger offsets even with good sync.

If offset seems high, wait 10-15 minutes for updated samples. NTP slowly adjusts your system clock to gradually minimize offset.

Step 4: View Detailed NTP Statistics

For a deep dive into the raw NTP adjustment data, use the ntpq tool:

ntpq -p

This shows:

  • Selected NTP server details

  • Latest measurement offset

  • Jitter, noise, delay values over time

Scan the output and observe the offset measurements between servers and your system. Very small offsets denote good synchronization.

Watch the output over some minutes to see the variation in readings. NTP works to average out the noise.

Step 5: Check Hardware/BIOS Clock Settings

As a final check, review that NTP has control of the system time and is not being overridden.

Some Linux distros sync the hardware clock to the BIOS by default instead of letting the OS handle it. This can disrupt NTP keeping consistent time.

Check your hardware clock behavior with:

timedatectl

Look at the "RTC in local TZ" line. It should show "no" for full NTP control. If set to "yes", update your distro settings to give NTP priority.

BIOS clock options may also need to be adjusted to avoid interference. Set to "UTC" time and disable automatic sync tools.

Summary

Following these 5 steps allows verifying your Linux machine has proper NTP time synchronization:

  1. Check the NTP service status

  2. Inspect date/time values

  3. Compare offset from NTP servers

  4. View detailed NTP stats

  5. Confirm hardware clock settings

With NTP actively minimizing time offset and no conflicts, you can rely on your Linux system clock to stay accurate for critical operations. Monitoring the sync quality gives peace of mind.

Over time, some drift naturally still occurs in Linux device clocks due to hardware imperfections. Regular small NTP adjustments compensate for this drift extremely well, usually keeping time error under a few milliseconds.

Maintaining NTP reliability does require pointing devices to accessible, low-latency NTP servers rather than just defaults. Well-connected public servers or local network time servers produce the best accuracy.

NTP has proven itself as a foundational technology for nearly 30 years. When configured properly, it brings robust and precise timekeeping to Linux systems as a crucial system service. Checking that your NTP implementation stays in sync is vital for leveraging accurate timestamps.


Also read -

How to Check NTP Version in Linux

A Beginner's Guide to Using nslookup on Linux

Mounting NFS Shares from a Linux Server on Windows 2012