I'm new-ish to systemd. I've got a service that's been working fine with the ExecStart command line hard-coded. Now I'm trying to parameterize it, and I found EnvironmentFile written up online. So I modified my service file as follows (some things obfuscated for privacy):

ExecStart=/usr/local/bin/my-service -port=$PORT -log-level=$LOG_LEVEL -creds=$CREDENTIALS_FILE
ExecStop=/bin/kill -15 $MAINPID

I checked, and the environment file /etc/my-service/my-service-systemd.cfg is definitely there:


But when I run the service, it fails, and the logs indicate that all parameters are coming in empty, i.e. the service file is not passing in values from the EnvironmentFile.

What am I doing wrong?


2 Answers 2


There are rules on the expansion of the $ prefix in ExecStart and so on. There is a difference between $var and ${var}. The former will only be interpolated if it occurs as a word on its own (surrounded by whitespace). The latter does not have this restriction. So use, for example,


The reference for this is under the heading COMMAND LINES in man systemd.service.


It may be related to file permissions. See if this fixes it:

chown root:root /etc/my-service/my-service-systemd.cfg 
chmod 0640 /etc/my-service/my-service-systemd.cfg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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