1

Testing OS: RHEL7

Required OSs: RHEL & Derivatives & AIX

I have a user that was created as follows:

sudo groupadd madt
sudo useradd -r -g madt -s /bin/false madt

That user is being used in a systemd service as follows:

[Unit]
Description=MicroStrategy Mobile Access Distribution Tool
After=syslog.target

[Service]
User=madt
ExecStart=/usr/bin/java -jar /opt/pandera/mobile-registration/mobile-access-distribution-tool-1.0.0.jar --spring.config.location=/opt/pandera/mobile-registration/
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

The java app requires that an environment variable be present. I've set the variable in /etc/environment and confirmed that it works for root and all other interactive users.

How can I get the madt user to recognize my environment variable?

adenix
  • 113
  • 3

1 Answers1

1

You can use EnvironmentFile line in your systemd unit.

For example

EnvironmentFile=/etc/environment

Systemd will then read your file and inject variables from file to your program's environment.

If you need to set only single environment variable only for this system unit, just use

Environment=VERBOSITY_LEVEL=1
Věroš K.
  • 530
  • 3
  • 10