Thursday, February 3, 2022

[SOLVED] Cannot disable systemd service

Issue

I've been using the dbus API from systemd and I've been enabling services with the EnableUnitFiles() function as detailed here rel="noreferrer">http://www.freedesktop.org/wiki/Software/systemd/dbus/

However, when I try to disable the same service with the command

systemctl disable "service_name"

and follow-up with a check to see if the service is disabled with

systemctl status "service_name"

it still reveals the service to be enabled. I am currently running Centos7.

Any insight would be appreciated as to why I cannot disable the service. Thanks!


Solution

Try the systemd mask command rather than disable:

systemctl mask <service_name>

The disable command still allows the service to be started, for example, in response to another service requesting it as a dependency (even if optional), or manually. However mask disables the service completely.

Also, I don't believe either mask or disable actually stop a running service: they just configure the startup of that service in the future. Therefore, you should also do systemctl stop <service_name>.



Answered By - Raman
Answer Checked By - Katrina (WPSolving Volunteer)