大网数据广告活动
服务器运维问答

What is the canonical method for removing a unit/service file from systemd?

· 52CE 我爱测

What is the systemd-approved method for removing e.g. sidekiq.service from /etc/systemd/system/ ? Note, there are many related discussions on this topic such as this one which I have already read: https://superuser.com/questions/…

问题原文

原帖链接 · afarley · CC BY-SA 4.0

What is the systemd-approved method for removing e.g. sidekiq.service from /etc/systemd/system/?

Note, there are many related discussions on this topic such as this one which I have already read: https://superuser.com/questions/513159/how-to-remove-systemd-services

My point of confusion is that the most-accepted answer in the above discussion requires the user to manually rm files from a bunch of locations, but a later answer suggests that systemctl disable <service> should have the same effect as manually removing the files.

According to my own testing of systemctl disable sidekiq, I am finding that the unit file sidekiq.service remains at /etc/systemd/system afterwards.

I understand that, in theory, using rm on a bunch of locations should do the trick, but I'm wondering how someone who is actually familiar with systemd or systemctl would do this. Is such brute force really necessary, or is there an actual systemctl command for this purpose?

已采纳解答

原帖链接 · Michael Hampton · CC BY-SA 4.0

If you're trying to uninstall software, then removing the file is the correct approach. But remember that systemd will remember the service until told to reload its configuration with systemctl daemon-reload. Then it will notice the unit is gone, and (if the service isn't still running) forget about it.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-02-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。