钟二网络头像

钟二网络

探索SQL查询技巧、Linux系统运维以及Web开发前沿技术,提供一站式的学习体验

  • 文章92531
  • 阅读805665
首页 Linux 正文内容

linux查看连接ntp

钟逸 Linux 2024-07-24 17:49:20 26

步骤1:查看NTP守护进程状态

使用以下命令检查NTP守护进程是否正在运行:

systemctl status ntpd

如果守护进程正在运行,您将看到类似以下内容:

● ntpd.service - Network Time Protocol Daemon

Loaded: loaded (/lib/systemd/system/ntpd.service; enabled; vendor preset: enabled)

Active: active (running) since Sun 2023-03-12 13:09:07 UTC; 1h 15min ago

Main PID: 4567 (ntpd)

CGroup: /system.slice/ntpd.service

└─4567 /usr/ in/ntpd -u ntp:ntp -p /var/run/ntpd.pid \

-g -i -b 0.050200 0.250100 -f /etc/ntp.conf -4 -6

Mar 12 13:10:19 hostname ntpd[4567]: listening on 0.0.0.0 123

Mar 12 13:10:19 hostname ntpd[4567]: listening on ::1 123

步骤2:查看已配置的NTP服务器

使用以下命令查看当前配置的NTP服务器:

cat /etc/ntp.conf | grep server

您将看到类似以下内容:

server ntp.ubuntu.com prefer

server ntp.google.com

server 0.ubuntu.pool.ntp.org

server 1.ubuntu.pool.ntp.org

步骤3:查看当前连接的NTP服务器

使用以下命令检查NTP客户端当前连接到的NTP服务器:

ntpq -p

您将看到类似以下内容:

remote refid st t when poll reach delay offset jitter

==============================================================================

*debian.pool.ntp. ubuntu.pool 1 u 18 64 377 0.724 0.113 0.208

ntp.ubuntu.com debian.pool 1 u 47 64 8 262.917 263.361 0.205

通过上述步骤,您可以轻松查看Linux系统与NTP服务器的连接状态,监控NTP守护进程,并获取已配置和当前连接的NTP服务器信息。这有助于确保您的系统能够准确地同步时间。

文章目录
    搜索