[systemd-devel] How can I simply check that a service has been restarted ?

Luca Boccassi bluca at debian.org
Tue Nov 10 17:22:33 UTC 2020


On Tue, 2020-11-10 at 18:12 +0100, Francis Moreau wrote:
> On Tue, Nov 10, 2020 at 2:43 PM Luca Boccassi <bluca at debian.org> wrote:
> > On Tue, 2020-11-10 at 11:50 +0100, Francis Moreau wrote:
> > > On Tue, Nov 10, 2020 at 11:30 AM Lennart Poettering
> > > <lennart at poettering.net> wrote:
> > > > On Di, 10.11.20 10:28, Francis Moreau (francis.moro at gmail.com) wrote:
> > > > 
> > > > > Hello,
> > > > > 
> > > > > After restarting a service with "systemctl try-restart ..." I want to
> > > > > verify that the service has been restarted.
> > > > > 
> > > > > How can I reliably do this without using the dbus API ?
> > > > 
> > > > D-Bus is how systemd exposes its state. If you don't want to use that,
> > > > you won't get the state information.
> > > > 
> > > 
> > > dbus is overkill for my little bash script.
> > 
> > It's pretty simple, and a one-liner, to get the value of a property
> > from a bash script with busctl. Eg:
> > 
> > $ busctl get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/gdm_2eservice org.freedesktop.systemd1.Service Restart
> > s "always"
> > 
> 
> Thank you but I'm not interested in the Restart property of a service,
> I want to know if a service as been restarted.

It's just an example on how to get D-Bus data on units easily from a
bash script.

-- 
Kind regards,
Luca Boccassi


More information about the systemd-devel mailing list