gpt4 book ai didi

systemd:覆盖单位文件时如何清除条目

转载 作者:行者123 更新时间:2023-12-04 19:02:21 30 4
gpt4 key购买 nike

我的机器上的服务具有一个默认的单位文件,该文件在PIDFile部分中指定了[Service]设置。我想清除此设置,以便未为该单元指定PID文件。

我已经创建了覆盖。 Systemd可以看到它,因此它可以正常工作,但是我不确定应该使用哪种语法来清除设置。我已经在我的替代中尝试过此操作:

[Service]
PIDFile=

但这会导致错误:
# systemctl daemon-reload
# systemctl status myservice.service
...
Jan 14 16:15:07 host systemd[1]: [/etc/systemd/system/myservice.service.d/override.conf:1] Not an absolute path, ignoring:

我也尝试过 PIDFile=none,但这也会导致错误。我应该如何清除此设置?

最佳答案

https://www.freedesktop.org/software/systemd/man/systemd.unit.html上有关于该主题的一些信息

Various settings are allowed to be specified more than once, in which case the interpretation depends on the setting. Often, multiple settings form a list, and setting to an empty value "resets", which means that previous assignments are ignored. When this is allowed, it is mentioned in the description of the setting.



但是,在 https://www.freedesktop.org/software/systemd/man/systemd.service.html上的 PIDFile指令的描述中,没有关于重置此值的信息,根据先前的引用,这意味着无法重置该值。

稍后,在示例2。覆盖供应商设置一节中,有一些有关从列表中删除条目的信息:

Note that for drop-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), such as ConditionPathExists= (or e.g. ExecStart= in service units), one needs to first clear the list before re-adding all entries except the one that is to be removed. See below for an example.



引用示例(为简洁起见,已编辑):

原始单位:
[Unit]
(...)
AssertPathExists=/srv/webserver

插入文件:
[Unit]
(...)
AssertPathExists=
AssertPathExists=/srv/www

也有以下声明:

Note that dependencies (After=, etc.) cannot be reset to an empty list, so dependencies can only be added in drop-ins. If you want to remove dependencies, you have to override the entire unit.

关于systemd:覆盖单位文件时如何清除条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34802345/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com