当我systemctl status在特定服务器上运行时,我得到以下输出:
? ?host-name?
State: degraded
Jobs: 0 queued
Failed: 1 units
Since: Fr 2017-06-09 00:34:27 UTC; 1 weeks 5 days ago
CGroup: /
…
Run Code Online (Sandbox Code Playgroud)
如何找出失败的服务是哪一个?
我尝试过systemctl is-failed '*',但是,这并不产生任何有意义的输出(它输出39行active一个failed行,然后一些更多(> 100)active行...)。
小智 8
尝试
sudo systemctl list-units --failed
Run Code Online (Sandbox Code Playgroud)
或者
sudo systemctl list-units --state=failed
Run Code Online (Sandbox Code Playgroud)
看来is-failed是错误的子命令\xe2\x80\xa6 谁会猜到。
这里有一些 Perl hacking 来获得正确的答案:
\n\n$ systemctl list-units | perl -lanE'print if $F[2] !~ /active/'\n UNIT LOAD ACTIVE SUB DESCRIPTION\n\xe2\x97\x8f vboxautostart-service.service loaded failed failed vboxautostart-service.service\n\nLOAD = Reflects whether the unit definition was properly loaded.\nACTIVE = The high-level unit activation state, i.e. generalization of SUB.\nSUB = The low-level unit activation state, values depend on unit type.\n\n207 loaded units listed. Pass --all to see loaded but inactive units, too.\nTo show all installed unit files use 'systemctl list-unit-files'.\nRun Code Online (Sandbox Code Playgroud)\n\n而且systemctl,以一种只得到我们想要的输出的方式将 stderr 与信息输出混杂在一起也是很好的。
| 归档时间: |
|
| 查看次数: |
8882 次 |
| 最近记录: |