以 root 身份运行时 Systemctl 命令超时

luj*_*jop 5 linux systemd

从今天起,当我尝试systemctl使用 root 帐户执行时,它们失败并出现Connection timed out错误:

>sudo systemctl
>Failed to list units: Connection timed out
Run Code Online (Sandbox Code Playgroud)

当以 root 身份运行时,systemctl start也会发生同样的事情。systemctl stop

如果我尝试使用用户帐户运行相同的命令,我不会收到错误Connection timed out(由于用户帐户缺乏权限,启动和停止会给出预期的错误)。

如果我重新启动服务器,我知道的所有服务都会正确启动,但我仍然遇到相同的超时错误。

PD:使用 openSuse 13.2(Linux 版本 3.16.7-21-默认)

luj*_*jop 5

终于我找到了问题所在。

我认为进程 1 (systemd) 是通过--switched-root--deserialize启动的。正如我在该链接中发现的那样,似乎有一些内部参数尝试重新加载一些以前保存的状态。

我已经在进程 1 上执行了kill -9,现在 systemd 出现而没有切换根目录,并且 systemctl 在重新启动或不重新启动的情况下都可以再次工作。

  • “kill -9 1”或“systemctl daemon-reexec”都不适合我,所以我求助于红色的大开关“rebo​​ot”。但这没有用!_(无法启动reboot.target:无法激活服务'org.freedesktop.systemd1':超时。有关详细信息,请参阅系统日志和'systemctl status restart.target'。无法打开/dev/initctl:没有这样的设备或地址。无法与 init 守护进程对话。)_ 经过一番谷歌搜索后,我发现 `systemctl --force --force restart` (https://ubuntuforums.org/showthread.php?t=2355822&p=13621891#post13621891) 做了重新启动并似乎恢复正常 (8认同)

小智 5

该问题的两种替代解决方案:

1-重新启动

systemctl --force --force reboot
Run Code Online (Sandbox Code Playgroud)

或者

2-无需重新启动,只需移动会话文件

mv /run/systemd/system/session-*.scope /tmp/
Run Code Online (Sandbox Code Playgroud)