12

A service on my machine has a default unit file that specifies the PIDFile setting in the [Service] section. I want to clear this setting, so that a PID file is not specified for this unit.

I've created my override. Systemd sees it, so it works properly, but I'm not sure what syntax I should use to clear the setting. I've tried this in my override:

[Service]
PIDFile=

But that results in an error:

# 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:

I've also tried PIDFile=none, but that also results in an error. How should I clear this setting?

dispree
  • 121
  • 1
  • 4

1 Answers1

17

There's some information on the subject at 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.

However in description of PIDFile directive at https://www.freedesktop.org/software/systemd/man/systemd.service.html there's no information on resetting this value which according to earlier quote means it can't be reset.

Later, in section Example 2. Overriding vendor settings, there's some information on removing entries from lists:

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.

Cited example (edited for brevity):

Original unit:

[Unit]
(...)
AssertPathExists=/srv/webserver

Drop-in file:

[Unit]
(...)
AssertPathExists=
AssertPathExists=/srv/www

Also there's following statement:

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.

Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366