1

I have a service file that runs off Red Hat 7 and I'm reading values from a conf file with EnvironmentFile. I need to how "catch" (and ignore) the error that the file may not exist, and start anyway.

I already tried using - as prefix of the directive, but it did not start.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
chuni
  • 23
  • 3

1 Answers1

2

The systemd.exec man page says, with my emphasis:

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.

So the syntax you need is:

EnvironmentFile=-/path/to/file

instead of:

-EnvironmentFile=/path/to/file
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250