LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 01-31-2018, 08:51 AM   #1
Richi
LQ Newbie
 
Registered: Jan 2018
Posts: 2

Rep: Reputation: Disabled
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
 
Old 01-31-2018, 12:20 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 02-01-2018, 02:52 PM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
https://wiki.archlinux.org/index.php/Systemd/User
 
1 members found this post helpful.
Old 02-02-2018, 03:36 AM   #4
Richi
LQ Newbie
 
Registered: Jan 2018
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post

That helps!

Thank you
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
systemctl start,enable service in one command. gctaylor1 Fedora 5 11-24-2018 12:20 PM
I am unable to start named.service using systemctl blason Linux - Server 6 09-30-2018 01:29 PM
[SOLVED] What is the purpose of systemctl start named.service? Echopurrs Linux - Newbie 1 07-07-2014 12:43 AM
systemctl start php-fpm.service question satimis Linux - Server 2 11-26-2012 07:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration