LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-20-2018, 09:17 AM   #1
pjbarberoiglesias
LQ Newbie
 
Registered: Jan 2011
Posts: 1

Rep: Reputation: 0
How to set variables to a non-login account used by a service in CentOS?


Hi there,

I would like to know what is the correct way to define and initialize variables to a non-login account (/usr/bin/false) that run a service on its behalf.

Regards.
 
Old 02-20-2018, 10:53 AM   #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
Put it in a wrapper script that calls the service.

e.g. If you run a command to start a service named "myservice" but want to set variable called OUTPUTDIR you'd create a simple script that does it:Z

Code:
!/bin/bash

export OUTPUTDIR=<value>

myservice
Alternatively if this is a cron job you could just create the script with the above export and call it before the service in crontab:

Script "myenv.sh"
Code:
!/bin/bash

export OUTPUTDIR=<value>
cron entry (in the crontab of the user you want this run as):
Code:
* * * * *  . /<pathto>/myenv.sh ; /<pathto>/myservice
Note that the cron entry "sources" myenv.sh rather than simply executing it.
 
  


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
Deleted default login account, now stuck on timer (no login) rrtn Linux - Newbie 4 12-11-2013 01:04 PM
[SOLVED] SSH - How can I only allow a key pair login for my user account not root account? shanekelly Linux - Security 5 01-25-2013 09:45 AM
Eee PC 1000 Linux Laptop - Just setup a login account for privacy, now can't login!!! martinkettle Linux - Laptop and Netbook 3 10-28-2008 05:21 AM
Cannot set LD_LIBRARY_PATH in .cshrc (able to set other env variables) senthilpr_in Linux - Newbie 4 02-26-2007 12:46 PM
is it legitimate and allowed and can be done to make another user account set uid and gid to null 0 to make another root account with different name and possibly not damage the debian system creating and using that new account BenJoBoy Linux - Newbie 12 01-29-2006 10:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:42 AM.

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