5

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?

  • 1
    Note that it is just an ordinary = assignment, not a second type of .INI file assignment syntax. – JdeBP Nov 13 '17 at 10:00
10

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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.