Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 running supervisord to execute gunicorn. My problem is when my script contains CURR_DIR=`pwd -P` and run the script via supervisord, it STOPS the process. My script is located in /var/www/conf and I expect `pwd P` to return /var/www/conf when I run the script. I tried PWD and that doesn't return /var/www/conf either. The `pwd -P` works when I run the script outside of supervisord.

But if I hardcode CURR_DIR=/some/dir then supervisord runs the script no problem.

Here's my script


CURRENT_DIR=`pwd -P`      # does not work: causes "STOPPED" error in supervisord
CURRENT_DIR=/var/www/conf # works ok

export GUNICORN_CONF=${CURRENT_DIR}/gunicorn.conf

echo "Starting $NAME"


exit 0

Here's the error message I get from supervisorctl shell:

supervisor> status
myscript                            STOPPED    Aug 27 09:57 PM

How can I make it so that I can run supervisord can run the above script?

share|improve this question

closed as unclear what you're asking by Falcon Momot, mdpc, Ward, gWaldo, TheCleaner Aug 29 '13 at 18:02

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

And I tried adding PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games. Does not work either. – Paul Aug 28 '13 at 4:14
Also, I enabled bash debugging using "!#/bin/bash -x" and the logs show me when I "echo `pwd -P`" or "echo $PWD" I only get "\". Strange. – Paul Aug 28 '13 at 6:12
Why do you think this is strange? What are you expecting ? – Iain Aug 28 '13 at 6:27
Please see BashFAQ/028. – Dennis Williamson Aug 28 '13 at 11:08
I am expecting /var/www/conf when I have pwd -P, because the script is located in /var/www/conf. I don't know why I got a -1. I will update my question to clarify this. – Paul Aug 29 '13 at 3:00
up vote 1 down vote accepted

You can't do what you want because the value returned by pwd is not guaranteed to be what you expect.

The location of the script is not it's working directory

$cat test

$ ./test

$ cd /tmp

See ? pwd is returning the current directory of the shell I used to invoke the test command. This is what is happening to you, you are seeing values inherited from supervisord.

If you read the document Dennis links to it provides useful information about how you may be able to solve your problem.

share|improve this answer

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