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

How are systemd/system overrides supposed to work?

· 52CE 我爱测

I'm messing around with some timeout settings, and am trying to figure out the correct way to set things for systemd/system daemons. Specifically, this is an underpowered server, and I keep timing out on starting clamd, so I'm tr…

问题原文

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

I'm messing around with some timeout settings, and am trying to figure out the correct way to set things for systemd/system daemons. Specifically, this is an underpowered server, and I keep timing out on starting clamd, so I'm trying to figure out how high I need to set the TimeoutStartSec parameter. I tried

systemctl edit --full clamd@.service

and edited it to say

TimeoutStartSec=20min

then did systemctl daemon-reload

But it kept mysteriously timing out after 7 minutes. Eventually, I found that /usr/lib/systemd/system/clamd@.service had TimeoutStartSec=420.

Probably against all Right Way to do things, I edited the /usr/lib version of the file, and commented out that line. Sure enough, that changed things, but it still doesn't seem to be reading the /etc/systemd version. Once I commented it out, it start timing out after 90 seconds, which I guess must be the default.

As a temporary workaround, I've edited the /usr/lib version to be my desired 20 minutes, but ... this doesn't seem like the right way to do things.

Is systemctl edit supposed to be editing the version in /etc/systemd/system? Is this the putatively correct way to do things? Do I have to do something more than systemctl daemon-reload?

Open to any and all suggestions on The Right Way to do this.

TIA

已采纳解答

原帖链接 · John Mahowald · CC BY-SA 4.0

systemctl daemon-reload is telling systemd itself to reload changed unit configuration. Not the software started by the unit, in this case clamd. (Despite the manual warning about this distinction, you are not the first be confused by it.)

Instead, use one of the unit commands, like systemctl reload-or-restart clamd@.service

Is systemctl edit supposed to be editing the version in /etc/systemd/system?

Yes. The idea is that /etc contains site-specific configuration, which overrides what the system package installed to /usr.

I would omit --full and create "drop-in" files with only the different options. Avoids maintaining an entire copy of the unit. For example systemctl edit clamd@.service edits a temporary file that will go somewhere like /etc/systemd/system/clamd@.service.d/override.conf and might contain just the different TimeoutStartSec=.

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

资料来源与适用范围

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

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

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