所以如果我运行,systemctl list-units --type=target
我就可以看到我的机器上的所有目标单元。
但是,如果我想找到每个“伞状”目标单位下的服务和其他单位的列表,我该怎么做呢?
换句话说,如果我看到journalctl
我有一个UNIT
xyz,我怎么知道该单位属于哪个目标?
我在日志消息中看到“达到目标<target_name>
”,但我很好奇哪些日志消息和单位导致达到该目标。
谢谢!
答案1
我认为您正在寻找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.
例如:
# systemctl list-dependencies zfs.target
zfs.target
● ├─zfs-mount.service
● ├─zfs-share.service
● ├─zfs-zed.service
● └─zfs-import.target
● └─zfs-import-cache.service