5

I have two services A and B which run continuously, for them I use systemd service units. At specific times service C should be run, I can do this using a timer and a service with the same name. C finishes after a short time. When C runs, A and B should not run. To ensure this, I use in the service file for C the Conflicts= option, which is explained on this webpage: systemd documentation. But this options only stops A and B. How can I start A and B again, when C finishes? Can I do this using systemd?

Note: To call systemctl start A.service and systemctl start B.service is not the kind of solution I am looking for.

  • 1
    I guess it's a dirty way to do that... can you trigger A and B in ExecStop of C? – Thushi Mar 1 '16 at 13:49
4

I would recommend using:

ExecStopPost=/usr/bin/systemctl start A.service B.service

Additional commands that are executed after the service is stopped

Using ExecStopPost instead of ExecStop is important because when ExecStop is run the service is still considered up, so the conflict will still apply.

  • Thanks for your answer, I will use your first suggestion. I think there is a misunderstanding, I have no objections to your first suggestion. – user5415068 Jul 1 '17 at 15:07

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.