ntpdate命令遇到“the NTP socket is in use, exiting”

来源:互联网 发布:2016年农业保险数据 编辑:程序博客网 时间:2024/06/06 05:27
#ntpdate pool.ntp.org15 May 10:51:02 ntpdate[50325]: the NTP socket is in use, exiting

这个提示表明NTP的端口已经被占用了,该端口默认为123,并且是UPD模式。可以使用nc或者netstat命令查看那个服务占用了此端口,例如:

nc -uz -w 3 172.0.0.1 123netstat -nupl | grep "123"

一般情况下,别的服务是不会占用这个端口的,所以可能的结果是ntpd服务在占用。此时,可以使用ntpdate命令的-u参数解决此问题,即:

# ntpdate -u pool.ntp.org15 May 11:19:13 ntpdate[28173]: adjust time server 202.118.1.81 offset -0.029390 sec

同步成功。参数u说明如下:

Direct ntpdate to use an unprivileged port for outgoing packets. This  is  most  useful  when behind  a firewall that blocks incoming traffic to privileged ports, and you want to synchronize with hosts beyond the firewall. Note that the -d option always uses unprivileged  ports.

简单的说明就是:它不再使用默认的端口,而是使用了一个别的端口,所以避免了端口冲突。

顺便附上公网上有效的几个ntpd服务器:

ntp.fudan.edu.cn (复旦) 

asia.pool.ntp.org(台警大授时中心-台湾)

time.windows.com (微软公司授时主机-美国) 

time.nist.gov (美国)

pool.ntp.org

0 0