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

Is it possible to extend the WantedBy systemd unit property?

· 52CE 我爱测

I have a unit file and I want to modify some of the properties. I've been able to extend all the properties using the /etc/systemd/system/unitname.service.d/ directory but cannot get the WantedBy property to be extended. Original…

问题原文

原帖链接 · vane · CC BY-SA 3.0

I have a unit file and I want to modify some of the properties. I've been able to extend all the properties using the /etc/systemd/system/unitname.service.d/ directory but cannot get the WantedBy property to be extended.

Original Unit File (deluged.service)

[Unit]
Description=Deluge Bittorrent Client Daemon
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=media
Group=media
ExecStart=/usr/local/bin/deluged -d -u 0.0.0.0

[Install]
WantedBy=multi-user.target

/etc/systemd/system/deluged.service.d/override.conf

[Unit]
BindTo=sys-subsystem-net-devices-tun0.device
After=sys-subsystem-net-devices-tun0.device

[Service]
ExecStart=
ExecStart=/usr/local/bin/deluged -d -i 10.10.10.1 -u 0.0.0.0

[Install]
WantedBy=
WantedBy=sys-subsystem-net-devices-tun0.device

Everything appears to work correctly except for WantedBy when I run systemctl enable deluged it still created the symlink in multi-user and no link is created in the new location.

I've searched for documentation on extending/overriding and I haven't seen anything talking about WantedBy so I have no idea if it's even possible to extend it. Am I doing something wrong or is it just not possible?

已采纳解答

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

Older systemd releases don't support overriding the [Install] section with drop-in files. With those you need to create a replacement file for this service, instead.

Similarly, the Conflicts= key in the [Unit] section can't be overridden in a drop-in file, either.


Systemd removed that limitation in the end of 2017, thus, versions released after that aren't affected.

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

资料来源与适用范围

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

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

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