Systemd:查找服务的依赖项

Rol*_*olf 12 dependencies systemd

systemctl list-dependencies postgres
Run Code Online (Sandbox Code Playgroud)

将列出服务的所有依赖项postgres。如何找到服务(或单位或目标)的所有依赖项?

Gry*_*ryu 10

$ systemctl list-dependencies systemd-sysusers.service --all --reverse
systemd-sysusers.service
? ??sysinit.target
?   ??accounts-daemon.service
?   ? ??graphical.target
?   ??acpid.path
?   ? ??paths.target
?   ?   ??basic.target
?   ?     ??multi-user.target
?   ?       ??graphical.target
Run Code Online (Sandbox Code Playgroud)

man systemctl

   list-dependencies [UNIT...]
       Shows units required and wanted by the specified units.
       This recursively lists units following the Requires=,
       Requisite=, ConsistsOf=, Wants=, BindsTo= dependencies. If
       no units are 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.

       Note that this command only lists units currently loaded
       into memory by the service manager. In particular, this
       command is not suitable to get a comprehensive list at all
       reverse dependencies on a specific unit, as it won't list
       the dependencies declared by units currently not loaded.
Run Code Online (Sandbox Code Playgroud)

  • `sudo systemctl daemon-reload` 是否有助于修复 _"... 因为它不会列出当前未加载的单元声明的依赖项"_ 参数? (2认同)