Discussion:
[systemd-devel] systemd-analyze for shutdown?
Nikolaus Rath
2016-05-27 15:46:07 UTC
Permalink
Hello,

Is there a way to run systemd-analyze for system shutdown, instead of
boot-up?

I am pretty sure that my system takes way longer than it should to power
off, but the "shutdown-log.txt" technique from
https://freedesktop.org/wiki/Software/systemd/Debugging/#index2h1
doesn't show anything obvious. So if there was a way to do
e.g. "systemd-analyze blame" for shutdown, that would help a lot.

Best,
-Nikolaus
--
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

»Time flies like an arrow, fruit flies like a Banana.«
Lennart Poettering
2016-05-27 16:32:53 UTC
Permalink
Post by Nikolaus Rath
Hello,
Is there a way to run systemd-analyze for system shutdown, instead of
boot-up?
I am pretty sure that my system takes way longer than it should to power
off, but the "shutdown-log.txt" technique from
https://freedesktop.org/wiki/Software/systemd/Debugging/#index2h1
doesn't show anything obvious. So if there was a way to do
e.g. "systemd-analyze blame" for shutdown, that would help a lot.
No, this is currently not available.

And it's not as easy to add actually. Note that systemd only keeps
units loaded as long as they are referenced by something else that is
loaded, are running, have failed, or have a job queued. That means if
a service is terminated at shutdown there's a very good chance it is
GC'ed away pretty quickly. Now, while systemd keeps timestamping info
around for services that tell us how long a service was running, took
to start or took to shut down all that info is lost the instant the
unit is GC'ed away...

To implement something like this we hence cannot just do what
"systemd-analyze blame" does, and iterate through the loaded units and
print their timestamp data, because most likely the units won't be
loaded anymore.

The right approach to implement this properly would probably be to log
the time data to the journal the instant a service is shut down, and
then make the tool read that back from the journal.

Anyway, for RFEs like this, please file an issue on github.

Lennart
--
Lennart Poettering, Red Hat
Loading...