Apr 15:48:18 ntpdate[124176]: the NTP socket is in use, exiting
在使用ntpdate配置时间同步的时候,如果之前已经配置过,会出现这个问题,我么需要把之前配置的残留删除,然后再配置。
您收到此错误消息的原因是由于 xntpd 已经绑定到了该 Socket。运行 ntpdate 时,它会首先进行广播,然后侦听端口 123。如果 xntpd 正在运行,而有一个进程已经在侦听该端口了,则会使 ntpdate 无法在上面运行。运行下列命令,即可找出 xntpd 的 PID
[root@saggitarxm bin]# ps -ef | grep xntpd
root 124185 6192 0 15:49 pts/1 00:00:00 grep xntpd
可惜没有找到pid。
使用:
lsof –i:123
没有lsof命令的话:yum install -y lsof
lsof -i:123
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ntpd 124171 ntp 16u IPv4 420557 0t0 UDP *:ntp
ntpd 124171 ntp 17u IPv6 420558 0t0 UDP *:ntp
ntpd 124171 ntp 18u IPv6 420562 0t0 UDP localhost:ntp
ntpd 124171 ntp 19u IPv6 420563 0t0 UDP [fe80::1251:72ff:fe31:f52b]:ntp
ntpd 124171 ntp 20u IPv6 420564 0t0 UDP [fe80::6a91:d0ff:fe60:a9d4]:ntp
ntpd 124171 ntp 21u IPv4 420565 0t0 UDP localhost:ntp
ntpd 124171 ntp 22u IPv4 420566 0t0 UDP 218.94.214.29:ntp
kill进程
[root@spark1 bin]# kill -9 12417
[root@spark11 bin]# ntpdate 192.168.100.120
13 Apr 09:08:36 ntpdate[124200]: step time server 192.168.100.120 offset -24096.422190 sec
[root@spark1 bin]# date
清除 (Kill) 该进程,然后尝试再次与 ntp 服务器进行同步。此时您不应该收到此错误消息。
请注意,如果您尝试与之同步的服务器没有运行 xntpd,则会收到下列错误消息:
ntpdate[12573]: no server suitable for synchronization found
出现这种情况的原因是,如果您想使用另一个服务器的时间,该服务器必须已经进行了自身同步。
Linux卫星对时:
自动对表:ntpdate asia.pool.ntp.org
ntpdate time.nist.gov同步网络时间
本文介绍了如何解决使用ntpdate命令时遇到的“NTP socket in use”错误,并提供了详细的步骤来定位并清除占用端口的进程,从而实现成功的时间同步。
4668

被折叠的 条评论
为什么被折叠?



