大多数systemd服务都可以通过该systemctl实用程序进行管理。在这种情况下,我们要禁用该systemd-oomd服务。这可以通过以下方式完成:
$ systemctl disable --now systemd-oomd
您应该会看到类似的内容(取决于您的操作系统):
$ systemctl disable --now systemd-oomd
Removed /etc/systemd/system/multi-user.target.wants/systemd-oomd.service.
Removed /etc/systemd/system/dbus-org.freedesktop.oom1.service.
然后,您可以使用以下方法验证该服务是否已禁用:
$ systemctl is-enabled systemd-oomd
然后你应该看到:
$ systemctl is-enabled systemd-oomd
disabled
但是,其他服务可能会尝试重新启动该systemd-oomd服务。为了防止这种情况,您可以“屏蔽”该服务。例如:
$ systemctl mask systemd-oomd
Created symlink /etc/systemd/system/systemd-oomd.service → /dev/null.
然后systemctl is-enabled现在应该报告:
$ systemctl is-enabled systemd-oomd
masked
更多man systemctl详情见;特别要注意有关屏蔽systemd服务的注意事项。
参考链接: