I would like to configure a not so common start sequence with systemd: Service A is required by service B only while service B is starting. Once Service B started, Service A can be stopped and Service B can go on running.

If Service B tries to start, and Service A is stopped, then one of these must happen: Service A must start or not. If not, Service B must not start.

So, Service A is required by Service B only at start time of B. Otherwise, Service A is irrelevant.

I have checked the system.unit options (requires, requisites, wants, before, after, etc), and I cannot find the right mix to achieve such behaviour.

  • If A isn't required by other services, then this logic can be implemented inside service B Oct 3, 2018 at 0:35
  • Yes, it truly could. We try to avoid additional scripts. Service A and Service B are two processes started by Out-Of-The-Box scripts. Service B does not implement the is-process-A-running check, but otherwise starts with errors. So, a solution would be to implement this checks in a script. We will try it and we will check if it is functional. We can have a lot of processess type B, but just one type A. So we do not like the idea of a single systemd unit starting services type B via the service@instance syntax, and checking for Service A at one time. Oct 3, 2018 at 5:01
  • If A is not needed by other parts of your system, then a separate service is not needed, a single service can contain any number of processes. I'm not talking about unit instance. A script check for the status of A(and run A if necessary) and then start B would solve your problem. Why do you avoid additional script? Oct 3, 2018 at 5:31

1 Answer 1


You could have B require A with Requires= and kill A using ExecStartPost= in B

  • We do not need Service A to get killed. Service A is also useful. But it is only mandatory at Service B startup. Oct 3, 2018 at 4:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.