Server Fault is a question and answer site for system and network administrators. 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

I'm trying to use the variables defined in /etc/environment in an upstart script.

I'm able to export the variable to the child process but for some reason I not able to use them in the upstart script stanza itself.

This works:

    . /etc/environment
    export NODE_ENV
    # node is able to read the NODE_ENV, wonderful!
    /usr/local/bin/node /path/to/app/app.js
end script

But if I try to introduce some conditional logic within the stanza then it will fail:


    . /etc/environment
    export NODE_ENV

    # ${NODE_ENV} is not set inside the stanza
    if [[ ${NODE_ENV} = 'production' ]]; then

        # this will never run
        /usr/local/bin/node /path/to/app/app.js

end script

Any ideas how I can access variables from sourced files inside the stanzas? I really don't want to have to hardcode this stuff!

share|improve this question
up vote 1 down vote accepted

The problem is your use of "[[". Upstart runs all scripts via /bin/sh. See:

If you look at the jobs log, you should see a (shell) error there:

sudo cat /var/log/upstart/your-job.log

share|improve this answer
thanks you solved my problem! – techjacker Mar 25 '13 at 18:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.