15

How can I set the Service WorkingDirectory using an environment variable? Here is an example service config:

[Service]
Environment=MYWORKINGDIR=/tmp
WorkingDirectory=${MYWORKINGDIR}

This generates an error along the lines of not an absolute path. Adding a slash to the start "fixes" that error, but the path is still not found:

[Service]
Environment=MYWORKINGDIR=/tmp
WorkingDirectory=/${MYWORKINGDIR}

Is this even possible? Documentation isn't clear on which directives can/can't use env variables.

http://www.freedesktop.org/software/systemd/man/systemd.exec.html

14

Is this even possible?

No, It's not possible.

You can use:

  • ~
  • absolute directory path
  • - absolute directory path

Also, WorkingDirectory understands specifiers.

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.