For regular systemd services it is possible to retrieve information about the most recent run via systemctl show ...
. I'm interested in state change time stamps (mainly when started and stopped). This works fine:
$ systemctl show -p ExecMainStartTimestamp,ExecMainExitTimestamp some-service
ExecMainStartTimestamp=Thu 2022-11-10 09:45:42 UTC
ExecMainExitTimestamp=Thu 2022-11-10 09:45:46 UTC
For instantiated services, however, this information is not provided after it exited:
$ systemctl show -p ExecMainStartTimestamp,ExecMainExitTimestamp other-service@abc
ExecMainStartTimestamp=n/a
ExecMainExitTimestamp=n/a
This looks similar to an instance which never ran (let's say other-service@xyz
). In fact all the properties provided via systemctl show
look exactly the same for a stopped instantiated unit and one that never ran.
I might get this information via journalctl
in a hacky way, but I would strongly prefer to get it from systemd directly.
Do I overlook something or is there a reason why systemd cannot provide this information?
UPDATE: It looks like systemd does preserve unit properties if the instantiated unit failed:
$ systemctl show -p ActiveState,ExecMainStartTimestamp,ExecMainExitTimestamp other-service@abc
ExecMainStartTimestamp=Sat 2022-11-19 22:07:38 UTC
ExecMainExitTimestamp=Sat 2022-11-19 22:07:43 UTC
ActiveState=failed
Still, for error-free runs this information is missing.