Is there any way to list systemd services in linux "in-the-order-of" they were loaded?
Asked Answered
A

2

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.

Autism answered 27/3, 2015 at 20:32 Comment(2)
Try systemctl list-dependencies. I think this is what you are looking for.Ypsilanti
systemctl list-dependencies will not account for more subtle service startup order, the correct answer is given by shibley (systemd-analyze plot)Smutch
E
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
Electronarcosis answered 27/3, 2015 at 22:49 Comment(2)
Cool stuff! Congrats for the postNidify
On dependency plot --order --require might be useful: selects which dependencies are shown in the dependency graph.Riel
M
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
    
Methacrylate answered 16/9, 2021 at 4:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.