所以如果我运行,systemctl list-units --type=target
我可以看到我机器上的所有目标单元。
但是,如果我想找到每个这些“伞形”目标单位下的服务和其他单位的列表,我该怎么做?
换句话说,如果我看到journalctl
我有一个UNIT
xyz,我怎么知道那个单位属于哪个目标?
我在日志消息中看到“达到目标<target_name>
”,但我很好奇导致达到该目标的日志消息和单位。
谢谢!
我想你正在寻找list-dependencies
。
从手册页:
list-dependencies [UNIT]
Shows units required and wanted by the specified unit. This
recursively lists units following the Requires=, Requisite=,
ConsistsOf=, Wants=, BindsTo= dependencies. If no unit is
specified, default.target is implied.
By default, only target units are recursively expanded. When --all
is passed, all other units are recursively expanded as well.
Options --reverse, --after, --before may be used to change what
types of dependencies are shown.
Run Code Online (Sandbox Code Playgroud)
例如:
# systemctl list-dependencies zfs.target
zfs.target
? ??zfs-mount.service
? ??zfs-share.service
? ??zfs-zed.service
? ??zfs-import.target
? ??zfs-import-cache.service
Run Code Online (Sandbox Code Playgroud)