1

I'm running RHEL 6.8 for this task. My goal is to create a service that is supposed to kick off a process (it's a Java app) that runs as a different user. The problem that I'm encountering is that whenever I start up this process as a different user, not all of the environment variables are included that of the user.

As user foo, logged in, I get one set of environment variables. As root, I get a second set. And when I do # sudo -E -u foo env I get a completely third set of variables.

Whenever I use gnome-terminal to run the same application, it works fine. All of the environment variables are included as they should be. My question is, how can I include the same environment variables while running the program as a service in run levels 3, 4 and 5?

I'd like to avoid having to hard code these variables in the script itself.

  • Why doesn't the service read its configuration options from a configuration file? Anyway, you may try to source the user's .profile or .bashrc before running the executable; this is highly unorthodox, because services should not run under interactive accounts. – AlexP Dec 7 '16 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.