Show journald logs from last service start

systemd logo

I needed to test something and was only interested in the logs since the last start/restart of a service. For this you can use the systemd invocation id from a systemd service.

You can check the current systemd invocation id like so:

systemctl show -p InvocationID --value kubelet.service

Then just use the _SYSTEMD_INVOCATION_ID option in journalctl to only see logs from the last service start:

journalctl -u kubelet.service _SYSTEMD_INVOCATION_ID="$(systemctl show -p InvocationID --value kubelet.service)"

Have fun!

Andrej Friesen
Andrej Friesen
Software & Systems Engineer

Andrej Friesen is a more or less classical engineer who followed his passion to IT.

comments powered by Disqus