[systemd-devel] How can I simply check that a service has been restarted ?
Lennart Poettering
lennart at poettering.net
Sat Dec 19 12:19:35 UTC 2020
On Mi, 18.11.20 09:15, Francis Moreau (francis.moro at gmail.com) wrote:
> >
> > Eg:
> >
> > $ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Service NRestarts
> > u 0
> >
>
> I didn't know NRestart property, thanks. But it only counts automatic
> restart, not manual one.
>
> And also there's no need to use busctl, for getting service properties
> I can use 'systemctl show -p'
I am not sure what you even mean by "has been restarted"? Compared to
when?
You could enquire the invocation ID of the service at two points in
time, and if it changed in between the service got restarted.
$ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Unit InvocationID
The invocation is randomly generated whenever a new start cycle begins.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list