You are not logged in.
Hello all,
Is it possible for a systemd service to stop another systemd service?
For eg:- Creating a A.service file and running it, and later creating a B.service file which would run a script which executes 'systemctl stop A.service'. Will running the service B stop the service A?
In my case, I'm running an instance of ifplugd@.service and an instance of netctl-auto@. service. What I would like is the netctl-auto@. service to stop, when I plug in the ethernet cable, which would be detected by the ifplugd@. service. The ifplugd service would then execute the ifplugd.action script. I've tried adding 'systemctl stop netctl-auto@wlo1.service' but it doesn't seem to work. Is there a way to fix this, or I'm tackling this in a completely wrong way?
Offline
I have the feeling that your way of doing this is not the right way.
You could try to use the 'conflicts=' option of the [UNIT] section of the service file:
Conflicts=
A space-separated list of unit names. Configures negative requirement dependencies. If a unit has a Conflicts= setting on another unit, starting the former will stop the latter and vice versa.
It's from 'man systemd.unit'.
Last edited by berbae (2014-12-29 21:45:17)
Offline