LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (https://www.linuxquestions.org/questions/red-hat-31/)
-   -   systemctl start myapp.service (https://www.linuxquestions.org/questions/red-hat-31/systemctl-start-myapp-service-4175622795/)

Richi 01-31-2018 08:51 AM

systemctl start myapp.service
 
Hello Community!

I have a Problem with starting my application via systemctl command.
The application run under a non root user and If i start the app with the Systemctl command, neccessary Environment variables doesn't apply.

I have set the User in the /etc/systemd/System/myapp.service file

Code:

[Service]
User=myuser

Starting the app the normal way works without Problems, because the Settings from
/home/myuser/.bash_profile are working.

How can I configure systemd, that only for myapp.service additional Environment Settings should be applied?

Thanks
Richi

MensaWater 01-31-2018 12:20 PM

I imagine this is for the same reasons you have when doing things through cron or older init scripts. To whit: The user environment is NOT invoked by background processes as it is by login shells.

Read this blog I wrote that talks about other things you'd need to include for a script running in cron or init. You likely need them for systemd as well.
https://www.linuxquestions.org/quest...-script-36931/

I found another link that talks about setting environment variables in systemd unit files:
https://coreos.com/os/docs/latest/us...emd-units.html

Using the principles from the first link and the method in the second link you should be able to determine what you need to add to your unit file.

ondoho 02-01-2018 02:52 PM

https://wiki.archlinux.org/index.php/Systemd/User

Richi 02-02-2018 03:36 AM

Quote:

Originally Posted by ondoho (Post 5814426)


That helps!

Thank you


All times are GMT -5. The time now is 11:03 PM.