我希望在Ubuntu 16.04.4上配置时间同步,但timedatectl给出创建总线连接失败:没有这样的文件或目录

当我查看https://help.ubuntu.com/lts/serverguide/NTP.html时,我可以看到timedatectl的当前时间配置,但我总是收到错误。

$ timedatectl status Failed to create bus connection: No such file or directory $ sudo timedatectl status Failed to create bus connection: No such file or directory # timedatectl status Failed to create bus connection: No such file or directory 

没有安装ntp软件包,服务正常运行。

 # systemctl status systemd-timesyncd * systemd-timesyncd.service - Network Time Synchronization Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled) Drop-In: /lib/systemd/system/systemd-timesyncd.service.d `-disable-with-time-daemon.conf Active: active (running) since Thu 2018-03-15 15:37:16 CET; 17h ago Docs: man:systemd-timesyncd.service(8) Main PID: 1801 (systemd-timesyn) Status: "Synchronized to time server 193.190.253.212:123 (1.be.pool.ntp.org)." CGroup: /system.slice/systemd-timesyncd.service `-1801 /lib/systemd/systemd-timesyncd Mar 15 15:37:16 linux-repo systemd[1]: Starting Network Time Synchronization... Mar 15 15:37:16 linux-repo systemd[1]: Started Network Time Synchronization. Mar 15 15:37:21 linux-repo systemd-timesyncd[1801]: Synchronized to time server 193.190.253.212:123 (1.be.pool.ntp.org). Mar 16 08:28:56 linux-repo systemd[1]: Started Network Time Synchronization. 

我在这里找到了解决方案:感谢您的回答,但我在这里找到了解决方案: https : //stackoverflow.com/questions/43907925/ubuntu-timedatectl-fails-in-docker-container

在最小的Ubuntu 16.04安装(像我的),没有安装dbus包。 所以apt-get install dbus解决了这个问题。

timedatectl尝试打开几个文件/ devies。 哦,他们在你的情况下失败了。 使用strace启动timedatectl并搜索错误消息:

 $ strace -o /tmp/timedatectl.log timedatectl status $ grep "^open(" /tmp/timedatectl.log ... open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 4 open("/dev/rtc", O_RDONLY|O_CLOEXEC) = 4 open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 4 ... 

如果您知道哪个文件/设备产生了问题,您可以开始修复它。