0

This is b.service:

[Unit]
Description=b.service
ConditionPathExists=/usr/sbin/b
Requires=a.service
BindsTo=a.service
After=a.service

[Service]
ExecStart=/usr/sbin/b

This does almost all I want:

  • If b.service starts, then a.service starts.
  • If a.service starts, then b.service starts.
  • If a.service stops, then b.service stops.

I would like to add the remaining dependency: if b.service stops, then a.service stops, without modifying the service file of a.service, if possible.

  • The dependency you want is "a requires b". Are you 100% sure about this? – Michael Hampton Sep 11 at 15:55
  • Well, if a isn't there, then b has no purpose running. If b isn't there, a can't work correctly. So, yeah? – Marki Sep 11 at 15:57
  • So you actually have a circular dependency? Are you really sure about this? It is NOT normal. – Michael Hampton Sep 11 at 16:00
  • 1
    superuser.com/questions/1025126/… suggests using a .target unit to coordinate multiple services – bodgit Sep 11 at 16:06
  • It just came to me that I can actually install an override file for a.service where I BindsTo=b.service... – Marki Sep 11 at 16:51
0

I have now additionally created an override for a.service in /etc/systemd/system/a.service.d/override.conf which defines:

[Unit]
BindsTo=b.service

Like this, a full dependency a if and only if b is fulfilled.

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.