Re: Question on Before=

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 02, 2019 at 03:03:22PM -0500, Steve Dickson wrote:
> 
> 
> On 2/2/19 2:48 PM, Tomasz Torcz wrote:
> > On Sat, Feb 02, 2019 at 02:42:15PM -0500, Steve Dickson wrote:
> >> Hello,
> >>
> >> In a.service  I have 
> >>
> >> [Unit]
> >> Before=b.service 
> >>
> >> [Install]
> >> RequiredBy=b.service
> >>
> >> when I systemd start b.service (which happens to fail) 
> >> but... a.service is not being run.
> >>
> >> So I guess my question is what do I have to do
> >> to ensure a.service is *always* run before b.service?
> > 
> >   Have you enabled a.service?
> > 
> No... I did not think I had to... I figured 
> when b.service was started, a.service would be 
> run regardless of being enabled or disabled.
> 
> Is that not the case?

  Not really.  It would work, if you had in b.service line like
Requires=a.service (*).
  But apparently you do not want to modify b.service, so you
put RequiredBy= in a.service's [Install] section. Directives
in [Install] section requires "systemctl enable" to have symlinks
created and to have effect. After enable, it will work identical to (*).

  Nb. most services have RequireBy=multi-user.target (or WantedBy=). For
such services, enabling mean they will start at boot (beacuse
multi-user.target is part of boot process).  But there is not
requirement for services to be Wanted/Required by not boot-related
services and target.
  Thus, you often find in tutorials assertion that 
"systemctl enable" equals "start during boot". This is not true.


-- 
Tomasz Torcz                "Funeral in the morning, IDE hacking
xmpp: zdzichubg@xxxxxxxxx    in the afternoon and evening." - Alan Cox

_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux