Sunday, 15 July 2012

linux - How do I access environment vars from processes running as services in centos? -



linux - How do I access environment vars from processes running as services in centos? -

we've started running our ec2 apps services creating /etc/init.d/[appname] script , executing using like:

service [appname] start|stop|restart

when doing this, however, our apps don't have access environment variables. how can process started service access environment vars? or, conversely, how can set environment vars can accessed processes running services? specifically, rely on these vars know environment running in... know...

a programme can access environment variables using environ variable or more getenv(3) library function.

you can query environment of process 1234 using /proc file system, notably thru /proc/1234/environ (be aware entries null terminated, read man page).

the starting scripts in /etc/init.d/ shell scripts can export foo=var set environment variable foo var within these scripts. (you need add together export line within script itself, or source file doing init script).

see this question.

linux service environment

No comments:

Post a Comment