41

On my Archlinux system, the /usr/lib/systemd/system/mdmonitor.service file contains these lines:

[Service]
Environment=  MDADM_MONITOR_ARGS=--scan
EnvironmentFile=-/run/sysconfig/mdadm
ExecStartPre=-/usr/lib/systemd/scripts/mdadm_env.sh
ExecStart=/sbin/mdadm --monitor $MDADM_MONITOR_ARGS

I suspect (confirmed by some googling) that the =- means that the service should not fail if the specified files are absent. However I failed to find that behaviour in the manpage of systemd unit files. Where is the official documentation for the =- assignment?

jan
  • 881
  • 2
  • 8
  • 18
  • 2
    Note that it is just an ordinary `=` assignment, _not_ a second type of .INI file assignment syntax. – JdeBP Nov 13 '17 at 10:00

2 Answers2

48

This is documented in systemd.exec:

EnvironmentFile=

[...]

The argument passed should be an absolute filename or wildcard expression, optionally prefixed with "-", which indicates that if the file does not exist, it will not be read and no error or warning message is logged.

And in systemd.service:

ExecStart=

… For each of the specified commands, the first argument must be an absolute path to an executable. Optionally, this filename may be prefixed with a number of special characters:

Table 1. Special executable prefixes

ExecStartPre=, ExecStartPost= … If any of those commands (not prefixed with -) fail, the rest are not executed and the unit is considered failed.

(To find the most complete documentation for a systemd directive, look it up in systemd.directives.)

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
5

Additionally, a line like

After=-.mount

looks like another "equals minus"-Syntax but instead is just an After= directive listing the special system unit -.mount, which is the root mount point. Docs: https://www.freedesktop.org/software/systemd/man/systemd.special.html#-.mount

klaus thorn
  • 151
  • 1
  • 2