web-dev-qa-db-ja.com

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.
4
Eric Baplue

私はここで解決策を見つけました:答えをありがとう、しかし私はここで解決策を見つけました: https://stackoverflow.com/questions/43907925/ubuntu-timedatectl-fails-in-docker-container

Ubuntu 16.04の最小インストール(私のような)では、dbusパッケージはインストールされません。したがって、apt-get install dbusは問題を解決しました。

6
Eric Baplue

timedatectlは、サーバーファイル/デバイスを開こうとします。それらのオーネはあなたの場合に失敗します。 timedatectlstraceを開始し、エラーメッセージを検索します。

$ 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
...

どのファイル/デバイスで問題が発生するかがわかっている場合は、修正を開始できます。

0
Simon Sudler