[systemd-devel] Binary launched in ExecStartPre gets killed...

Lennart Poettering lennart at poettering.net
Mon Mar 4 10:01:01 PST 2013

On Mon, 04.03.13 15:25, Belal, Awais (Awais_Belal at mentor.com) wrote:

> Hi,
> So how do i write such a service i.e. when A starts B should be
> started first and when A is stopped B should be stopped as well. I am
> really new to this so any pointers here would be really helpful. I
> understand that this is a very basic question but I am very new to
> this...

In this case write two normal .service files for these services. Then,
to link them together Add "BindTo=" to their [Unit] sections, pointing
to the other unit. This would then make sure, that if one is started,
the other is too, and if one is stopped the other is too, and both would
be equivalent (are they really? usually they aren't, but you description
above suggests two services where one cannot exist without the other,
and vice versa...). In addition to that add "After=B.service" to
A.service. (or, alternatively, "Before=A.service" to B.service, which
would be equivalent.) Please note that ordering deps are orthogonal to
requirement deps. That means that "BindTo=" does not imply ordering, and
hence you need both 'BindTo=' and 'After=' (or 'Before=') in the [Unit]


Lennart Poettering - Red Hat, Inc.

More information about the systemd-devel mailing list