Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check whether NTP is synchronized under Linux

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to check NTP synchronization under Linux", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "how to check NTP synchronization under Linux" this article.

NTP is used to synchronize the time of a computer client or server to another server or reference clock source. It uses UTC as the time standard, is an application layer protocol based on connectionless IP protocol and UDP protocol, and uses a hierarchical time distribution model. The accuracy that can be achieved depends on the accuracy of local clock hardware and strict control of device and process delay.

There are three commands in Linux that can be used to verify NTP synchronization. The details are as follows. In this article, we will show you how to use all of these commands to verify NTP synchronization.

Ntpq:ntpq is a standard NTP query program. Ntpstat: displays the synchronization status of the network world. Timedatectl: it controls the system time and date in the systemd system.

Method 1: how do I use the ntpq command to check the NTP status?

The ntpq utility is used to monitor the operation of the NTP daemon ntpd and determine performance.

The program can be run in interactive mode or controlled by command line parameters. It prints out a list of connected peers by sending multiple queries to the server. If NTP works properly, you will get output similar to the following.

# ntpq-p remote refid st t when poll reach delay offset jitter====*CentOS7.2daygee 133.243.238.163 2 u 14 64 37 0.686 0.151 16.432

Details:

-p: prints a list of peers known to the server and a summary of their status.

Method 2: how do I use the ntpstat command to check the NTP status?

Ntpstat reports the synchronization status of the NTP daemon (ntpd) running on the local computer. If the local system is found to be synchronized with the reference time source, ntpstat reports approximate time accuracy. The ntpstat command returns three status codes based on the NTP synchronization status. The details are as follows. 0: returns 0 if the clock is synchronized. 1: returns 1 if the clock is out of sync. 2: if the clock state is uncertain, 2 is returned, for example, if ntpd is unreachable.

# ntpstatsynchronised to NTP server (192.168.1.8) at stratum 3 time correct to within 508 ms polling server every 64 s method 3: how to use the timedatectl command to check NTP status?

The timedatectl command is used to query and change the system clock and its settings in systmed systems.

# timedatectl or # timedatectl status Local time: Thu 2019-05-30 05:01:05 CDT Universal time: Thu 2019-05-30 10:01:05 UTC RTC time: Thu 2019-05-30 10:01:05 Time zone: America/Chicago (CDT -0500) NTP enabled: yesNTP synchronized: yesRTC in local TZ: no DST active: yesLast DST change: DST began at Sun 2019-03-10 01:59:59 CST Sun 2019-03-10 03:00:00 CDTNext DST change: DST ends (the clock jumps one hour backwards) at Sun 2019-11-03 01:59:59 CDT Sun 2019-11-03 01:00:00 CST more tips

Chrony is an alternative to the NTP client. It can synchronize the system clock faster, has higher time accuracy, and is especially useful for systems that are not online all the time.

Chronyd is smaller, uses less memory, and wakes up CPU only when necessary, which can better save power. Even if the network is congested for a long time, it can run well.

You can use any of the following commands to check the Chrony status.

Check the Chrony trace status.

# chronyc trackingReference ID: C0A80105 (CentOS7.2daygeek.com) Stratum: 3Ref time (UTC): Thu Mar 28 05:57:27 2019System time: 0.000002545 seconds slow of NTP timeLast offset: + 0.001194361 secondsRMS offset: 0.001194361 secondsFrequency: 1.650 ppm fastResidual freq: + 184.101 ppmSkew: 2.962 ppmRoot delay: 0.107966967 secondsRoot dispersion: 1.060455322 secondsLeap status: Normal

Run the sources command to display information about the current time source.

# chronyc sources210 Number of sources = 1MS Name/IP address Stratum Poll Reach LastRx Last sample==== ^ * CentOS7.2daygeek.com 2 6 17 62 + 36us [+ 1230us] + /-1111ms

The above is all the contents of the article "how to check whether NTP is synchronized under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report