如何删除丢失的 systemd 单元?

And*_*inn 53 systemd coreos

我无法弄清楚如何删除不再有文件的 systemd 单元。他们似乎仍然以某种方式徘徊在系统中。

我试图删除的旧损坏单元:

core@ip-172-16-32-83 ~ $ systemctl list-units --all firehose-router*
  UNIT                       LOAD      ACTIVE SUB    DESCRIPTION
<E2><97><8F> firehose-router@02.service not-found failed failed firehose-router@02.service
<E2><97><8F> firehose-router@03.service not-found failed failed firehose-router@03.service

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

2 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
Run Code Online (Sandbox Code Playgroud)

这些文件不存在,但重新加载仍然有这些单位挥之不去:

core@ip-172-16-32-83 ~ $ systemctl list-unit-files firehose-router@02.service
core@ip-172-16-32-83 ~ $ sudo systemctl daemon-reload
core@ip-172-16-32-83 ~ $ systemctl list-units --all firehose-router*
  UNIT                       LOAD      ACTIVE SUB    DESCRIPTION
<E2><97><8F> firehose-router@02.service not-found failed failed firehose-router@02.service
<E2><97><8F> firehose-router@03.service not-found failed failed firehose-router@03.service

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

2 loaded units listed.
To show all installed unit files use 'systemctl list-unit-files'.
Run Code Online (Sandbox Code Playgroud)

我找不到与它们相关的文件:

core@ip-172-16-32-83 ~ $ sudo find /var/run/systemd -name "*firehose-router*"
core@ip-172-16-32-83 ~ $ find /etc/systemd/ -name "*firehose-router*"
core@ip-172-16-32-83 ~ $ find /usr/lib/systemd/ -name "*firehose-router*"
core@ip-172-16-32-83 ~ $
Run Code Online (Sandbox Code Playgroud)

那么我该如何摆脱这些呢?

小智 99

你所追求的命令是 systemctl reset-failed

  • 这最终清理了一个“真正的”服务,但我有一个拒绝消失的别名服务。我尝试了`disable`、`daemon-reload`和`reset-failed`,但别名服务总是显示为`not-found inactive dead`。我还搜索了磁盘以查找与服务名称匹配的任何内容,但没有结果。 (6认同)
  • 我刚遇到这个问题,`systemctl stop &lt;service&gt;` 对我有用。 (5认同)
  • 谢谢!我不知道为什么这对我来说不是更明显...... (3认同)