I'm trying to stop the Mosquitto broker service on a centos 7 server.
I've stopped the service with
sudo systemctl stop mosquitto.service
then I've disabled it with
sudo systemctl disable mosquitto.service
with ps I still get
/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
if I kill it, it autorestarts automatically and even after a reboot It's still running.
The process is owned by an other user (admin). How can I stop it definitively?
This has nothing to do with mosquitto but how systemd manages its services.
systemctl disable
only affects the autostart of the service but a disabled service will still get started if another service depends on it.
Lets say you have got a service mqtt-client
depending on mosquitto
with e.g. Wants=mosquitto
. Every time mqtt-client
is started the mosquitto
service gets started as well, even if it is disabled.
So one way is either to prevent mqtt-client
from starting as well (and all other services which depend on mosquitto
) or remove the dependency.
Another approach is to totally prevent the service from being loaded by masking it:
systemctl mask mosquitto
- this way you can neither start it manually nor by another service.
I would recommend reworking your dependencies in the long run since masking will just create a symlink to dev/null
so nothing happens if service gets loaded and you are not able to start it by yourself without unmasking it first.