Using variable in command path for ExecStart in systemd service
You can't use variables in the actual command. systemd.service:
The command to execute must be an absolute path name. It may contain spaces, but control characters are not allowed.
You might wan't to wrap it in a shell command (which does parameter expansion):
ExecStart=/bin/bash -c '/${TESTEXTSERVICESFILES}/syslog/bin/nxlog -c ${TESTCONFDATA}/syslog/nxlog.conf'
Instead of Environment=
, use EnvironmentFile=
, to define multiple environment variables.
[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/customsyslog
ExecStart=/bin/echo ${TESTEXTSERVICESFILES}/syslog/bin/nxlog $TESTCONFDATA
/etc/sysconfig/customsyslog
would contain key=value
pair, e.g.,
TESTEXTSERVICESFILES=/opt/test/extservices
TESTCONFDATA=/storage/test/conf