Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have an application I am deploying to an Ubuntu 12 server. My application has several "parts" to it:

There's a web server, run as part of an upstart script There are cron jobs There are sometimes command-line utilities which I want to run when ssh-ing into the production machine

What I want is a single place to specify a list of environment variables (MY_APP_HOME, MY_APP_CONFIG_1, etc...), which will be picked up by all of those above-mentioned "parts": by the upstart script, by the cron jobs, by the login shell when I ssh into the machine.

So, questions:

1) Where's the right place to place these? Specifically -- is it /etc/environment? Isn't that only for login sessions?

2) If it is /etc/environment -- I notice I can't use substitutions there, or run logic. Is there any place I can do that? A set of shell commands that get source'd?

share|improve this question
    
Normally you would update your upstart script, cron jobs, and utilities to read from a config file of your own doing; rather than modify the global config. – SlightlyCuban Oct 1 '13 at 14:45

For simple programs /etc/myapp e.g. /etc/wgetrc Complex programs use a directory /etc/myapp or /etc/myapp.d e.g. /etc/apache2 or /etc/logrotate.d A .d in directory names typically indicates a directory containing many configuration files or scripts for a particular situation

I think its cleaner to use your own files and to set them for a user in /home/user/.bashrc than to change system wide options. If you must set it systemwide then in /etc/profile.d/myapp.sh

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.baseadmn/doc/baseadmndita/etc_env_file.htm

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .