[systemd-devel] systemd unit transition timestamps

Uoti Urpala uoti.urpala at pp1.inet.fi
Thu Jun 10 16:17:41 UTC 2021


On Thu, 2021-06-10 at 10:49 +0000, paul.nieleck at fujitsu.com wrote:
> So, anyways, I don't see the difference between the units that causes the
> different behavior. Furthermore, from my point of view (as a user) it
> contradicts the description of the Timestamp values in the man page somehow,
> where it says "recorded on this boot".
> 
> Is this behaviour intended? Or is there another way to read the times a unit
> was stopped, without setting up my own event listener or searching the
> (potentially rotated/vacuumed) journal?

My guess is that after stopping the units, nothing references them any
more, and thus systemd garbage collects the unit data structures.
Systemd does not keep a record of all previously-used but no longer
relevant units in memory. Thus no record remains (outside logs) that
the unit was ever running, and there is no data stored about it. In the
docker.service case there may be another active unit that references
docker.service and thus keeps it loaded in memory.


> Is this behaviour intended? Or is there another way to read the times a unit
> was stopped, without setting up my own event listener or searching the
> (potentially rotated/vacuumed) journal?

I don't believe that the systemd daemon keeps any record about no-
longer-relevant units that were once active in the past, so there is
nothing to read later. So the alternatives are to read logs for past
events, record the event as it happens with a listener, or possibly
create a dummy active service that references the one you care about
and so keeps the data structure inside systemd alive.



More information about the systemd-devel mailing list