How to check environment variables for a systemd process

my problems seems to be a little more tricky…I have a systemd-service, that runs under a system user, which is set as nologin-user (for safety reasons).
When I start the service, it receives a config file for the environment:

#Set the environment variables that GNU Health needs

How can I check that the service really uses the environment variables in that configfile?
systemctl status … does not give the right answers…

Does it use the variables during startup, or just needs them at runtime?

This is my htop one, it uses the variables else it won’t start :wink:

It is not quite clear to me where you set that process environment variable. Putting the statement in a config file does not do much.What is done with that config file. In other words, what reads that config file and then executes that setting so that it is in the environment of a process and its offspring?

The env command prints the environment, thus

env | grep EnvironmentFile

will show if that variable is defined and what the value is of the current shell process where you are executing the env command. Of course it will then also be available to all child processes started from that shell.

@Malcolm: it needs them at runtime. BTW, what does the ‘-’ in front of the path (EnvironmentFile=-/etc/sysconfig/htop) do?

@hcvv: The settings are triggered during the startup of the service, see

I have no idea how I could get into the process that runs the service, in order to see the the env for that process.
The definitions in that rc file are:

test@linux-q6gm:~> more /etc/tryton/gnuhealthrc
alias cdlogs=‘cd /var/log/tryton’
alias cdexe=‘cd $(ls -d /usr/lib/python3.* )/site-packages/trytond’
alias cdconf=‘cd /etc/tryton’
alias cdmods=‘cd $(ls -d /usr/lib/python3.* )/site-packages/trytond/modules’
alias editconf=‘${EDITOR} /etc/tryton/trytond.conf’
alias cdutil=‘cd /usr/bin’

Actually, the client should read the GNUHEALTH_VERSION from the server’s environment, but that seems to fail somehow. So, I’m checkeing step for step…

That “-” just means skip it if it doesn’t exist…

All the definitions used are in (I hate to say, the man page…) man systemd.exec which I think will give you the pointers you need.

You can set the version in your service file via;


The others are aliases and should be sourced in your start script (trytond) rather than via the service file;


<add a test to check it exists, else exit>
<if it exists then source it, {the period will do that}>
. /etc/tryton/gnuhealthrc

tr '\0' '
' < /proc/$PID/environ

@arvidjar: Excellent hint, thanks!

@malcolmlewis: sure, setting this in the service file would be an option (may do this for testing purposes).
For the moment, all the settings in the gnuhealthrc are copied from /etc/bash.bashrc.local , which is generated in the specfile during the build process. Subject to improvement, but first getting it running.

After some fiddeling I found that the entry in the configuration file is just
variable = value (and no EXPORT or similar like on the bash side of life)

Thanks Gentlemen!