Without having to manually trace dependencies, e.g. with systemctl show or systemctl cat, and manually inspect the state of the system with systemctl status and systemctl list-units, is there a way to preview what a systemctl stop|start|restart would do?

Failing that, after the fact, is there a way to show a trace of which jobs were queued and why?

The kind of trace I would like to see in either case is something like:

starting X due to user request
adding Y to the transaction because it is required by X
adding Z1, Z2, Z3 because they are wanted by Y

PS: The --dry-run option is only available on later versions of systemd than the one I have, and is documented to only be supported on certain operations that are not relevant for my use case.

  • PPS: I tried a systemctl poweroff --dry-run on my workstation (systemd version 237) as a normal non-root user, and it simply ignored the --dry-run option and shut my computer down. A bug in systemd, or a lack of understanding of the documentation on my part?
    – Amir
    Jan 16 '19 at 12:31
  • Have you looked at systemctl list-dependencies <unit>? Jan 16 '19 at 15:49
  • Yes, list-dependencies is in the same category as show, cat etc., i.e. requires manual work to interpret for my use case. For one thing, it does not seem to follow the symlinks for WantedBy=, so some units are obviously missing from the list.
    – Amir
    Jan 16 '19 at 21:13

It depends: If other units do not rely on your unit, you could replace the actual commands you unit executes with a dummy command that just prints or logs its parameters. However for daemon-like processes it would be a bit tricky as they should not terminate.

As some units can only work when other units were started actually, simulation is always limited.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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