Score:0

How to get information about an instantiated systemd service after it exited

tg flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.