18

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.

user3128488
  • 367
  • 1
  • 2
  • 7
  • Try `systemctl list-dependencies`. I think this is what you are looking for. – alvits Mar 28 '15 at 00:30
  • `systemctl list-dependencies` will not account for more subtle service startup order, the correct answer is given by shibley (`systemd-analyze plot`) – Edward Aug 28 '19 at 08:17

2 Answers2

30

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
shibley
  • 1,528
  • 1
  • 17
  • 23
  • Cool stuff! Congrats for the post – imjoseangel Nov 22 '20 at 17:36
  • 1
    On dependency plot `--order --require` [might be useful](https://www.freedesktop.org/software/systemd/man/systemd-analyze.html#Options): selects which dependencies are shown in the dependency graph. – Pablo Bianchi Jul 30 '22 at 05:34
3

@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
    
Alex Waygood
  • 6,304
  • 3
  • 24
  • 46
kral2
  • 123
  • 1
  • 8