无法启动 ntpd.service

yyi*_*yin 1 ntp

首先,我ntp通过安装包sudo apt-get install ntp

我访问/etc/ntp.conf以根据国家/地区将服务器更改为几个本地服务器,然后我保存并使用它重新启动它,sudo systemctl restart ntp然后检查sudo systemctl status ntp显示运行的状态。

我也做了ntpq -p这给出了以下结果,我认为这意味着客户端正在运行:

    remote          refid   st t when poll reach   delay   offset  jitter
==============================================================================
 ntp.ubuntu.com  .POOL.         16 p    -   64  0   0.000   0.000   0.000
*time-a-g.nist.g .NIST.         1 u -   64   77   11.567   -7.287   7.636
-174.138.107.37  46.243.26.34   2 u   63   64   37   84.975 0.159   4.474
-ns3.weiszhostin 128.138.141.172  2 u   1   64   77   69.844  -11.884   6.043
+li290-38.member 128.138.141.172  2 u   65   64   37   43.448   -3.202   6.023
+pugot.canonical 145.238.203.14   2 u   61   64   37   79.540   -5.833   4.040
+alphyn.canonica 132.246.11.231   2 u   4   64   77   11.714   -5.017   7.244
+chilipepper.can 145.238.203.14   2 u   61   64   37   78.136   -4.269   4.769
+golem.canonical 145.238.203.14   2 u   55   64   37   81.139   -3.766   4.748
Run Code Online (Sandbox Code Playgroud)

但是,我似乎无法运行守护程序。我在做的时候发现了这一点sudo systemctl status ntpd,然后它给出了以下结果:

ntpd.service 
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
Run Code Online (Sandbox Code Playgroud)

我一开始以为它没有开始,所以我做了sudo systemctl start ntpd,但它给出了:

Failed to start ntpd.service: Unit ntpd.service not found.

那时我发现事情严重错误,我检查ls -l /etc/init.d并发现只有ntp在列表中,ntpd无法找到。我也尝试重新安装,ntp但这没有帮助。

有任何想法吗?非常感谢!

小智 7

在我的 Ubuntu 18.04 LTS 上这是一个很长一段时间的问题。它已启用,但处于非活动状态,因此每次重新启动后我都必须手动启动它。

$ sudo systemctl status ntp.service

? ntp.service - Network Time Service
   Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:ntpd(8)
Run Code Online (Sandbox Code Playgroud)

原因是与 service systemd-timesyncd.service冲突,它是 systemd 的一部分。在我禁用它后 ntp.service 开始成功启动。

$ sudo systemctl show ntp.service | grep Conflicts
Conflicts=shutdown.target systemd-timesyncd.service
$ sudo systemctl status  systemd-timesyncd.service
? systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-07-12 05:17:21 UTC; 18min ago
$ dpkg -S /lib/systemd/system/systemd-timesyncd.service
systemd: /lib/systemd/system/systemd-timesyncd.service
$ sudo systemctl disable systemd-timesyncd.service
Removed /etc/systemd/system/sysinit.target.wants/systemd-timesyncd.service.
Run Code Online (Sandbox Code Playgroud)