21

I am trying to understand the dependencies between different systemd services in my new project. We are using yocto build system and systemd/system services.

If I perform,

systemctl -l

It will list all the services in alphabetic order. But I am specifically looking for any commands/scripts that can be used for listing systemd services "in-the-order-of" they were loaded.

Please help.

2
  • 1
    Try systemctl list-dependencies. I think this is what you are looking for.
    – alvits
    Commented Mar 28, 2015 at 0:30
  • systemctl list-dependencies will not account for more subtle service startup order, the correct answer is given by shibley (systemd-analyze plot)
    – Edward
    Commented Aug 28, 2019 at 8:17

2 Answers 2

35

Unfortunately, due to the parallel nature of the boot up process and the potentially complex dependency relationships among services, the service start up order isn't very deterministic. However, systemd-analyze, if present on your system, can graphically plot the start up order of services:

systemd-analyze plot > startup_order.svg

It can also be used to graphically plot service dependencies:

systemd-analyze dot | dot -Tsvg > systemd.svg
2
  • Cool stuff! Congrats for the post Commented Nov 22, 2020 at 17:36
  • 1
    On dependency plot --order --require might be useful: selects which dependencies are shown in the dependency graph. Commented Jul 30, 2022 at 5:34
4

@shibley's tip with systemd-analyze is Great. Adding other helpful systemd-analyze commands here as I can't comment yet ...

  1. Finding which service have the biggest impact on the boot time:

    systemd-analyze blame
    
  2. Print a tree in the terminal of the service dependencies with timing impact

    systemd-analyze critical-chain
    

Not the answer you're looking for? Browse other questions tagged or ask your own question.