如何列出 systemd 中某个服务启动后启动的所有服务

如何列出 systemd 中某个服务启动后启动的所有服务

我想通过这种方式(如果可能的话)找到哪些服务正在等待网络管理器-等待在线.服务在开始之前执行?

答案1

我认为您正在寻找的命令是:

$ systemctl list-dependencies --reverse NetworkManager-wait-online.service 
NetworkManager-wait-online.service
● └─network-online.target
●   └─hddtemp.service

man systemctl

   list-dependencies [NAME]
       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.

   --reverse
       Show reverse dependencies between units with list-dependencies,
       i.e. follow dependencies of type WantedBy=, RequiredBy=, PartOf=,
       BoundBy=, instead of Wants= and similar.

相关内容