问题原文
原帖链接 · Andy Shinn · CC BY-SA 3.0
I'm having trouble figuring out how to remove systemd units that no longer have files. They still seem to linger in the system somehow.
The old broken units I am trying to remove:
core@ip-172-16-32-83 ~ $ systemctl list-units --all firehose-router*
UNIT LOAD ACTIVE SUB DESCRIPTION
<E2><97><8F> [email omitted] not-found failed failed [email omitted]
<E2><97><8F> [email omitted] not-found failed failed [email omitted]
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'.
The files do not exist, yet a reload still has these units lingering:
core@ip-172-16-32-83 ~ $ systemctl list-unit-files [email omitted]
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> [email omitted] not-found failed failed [email omitted]
<E2><97><8F> [email omitted] not-found failed failed [email omitted]
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'.
There are no files related to them that I can find:
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 ~ $
So how do I get rid of these?
社区高分解答
原帖链接 · AaronDanielson · CC BY-SA 4.0
When systemd analyzes unit definition files, it takes note of any other related units called out in the file - whether those other units exist or not.
$ systemctl --state=not-found --all
> ( ...prints list of 'not-found' units )
$ grep -r "<missing-unit>" /usr/lib/systemd/system
> ( returns files with references to <missing-unit> )
When a unit shows up as "not-found", it's not necessarily an error - all we know is, a local unit definition claims to have some relationship with it. This relationship might not be one we care about. For example, it could be "Before:" some other unit, but we don't use that other unit.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
