[systemd-devel] Antw: Re: Re: [EXT] Re: Q: Querying units for "what provides" a target
Andrei Borzenkov
arvidjaar at gmail.com
Fri Sep 9 11:41:28 UTC 2022
On Fri, Sep 9, 2022 at 2:13 PM Ulrich Windl
<Ulrich.Windl at rz.uni-regensburg.de> wrote:
...
> >
> > If you are interested in services that pull in e.g. time-sync.target
> > via Wants (or Requires) and order themselves before the target, you
> > can use something like
> > $ systemctl show time-sync.target -p WantedBy -p RequiredBy -p After
> > RequiredBy=
> > WantedBy=chrony.service
> > After=chrony.service time-set.target
>
> It seems what I wanted to know is output by
> # systemctl show -p After time-set.target
> After=systemd-timesyncd.service
> # systemctl show -p After time-sync.target
> After=time-set.target ntp-wait.service
>
> However the "After=" is somewhat unexpected.
This is exactly what targets are about. The only usage for targets is
to wait until something else becomes active and to do it they must
come After something.
> And "-p WantedBy" is definitely
> wrong (it will output units that "require the target", not the units "providing
> the target").
>
There is no such thing as "units providing the target". Systemd
documentation makes distinction between targets that Want other units
("active") and targets that are WantedBy other units ("passive"). It
is expected that services "providing" passive targets have
WantedBy=this-passive.target, otherwise passive targets will not be
activated at all. So WantedBy is exactly correct in this case.
More information about the systemd-devel
mailing list