I'm beginning to use supervisord to control services in my server. I'm not a pro user of linux but can get with it quite well and get it running.

Just out of curiosity, I've noticed that most commands in supervisord seem to be called like:

command=bash -c "/src/etc/install.sh"

I've read bash's man, and know that -c should be used to insert variables passed after the string.

So what's the point in using bash -c in supervisor (or any other place) instead of calling the script directly (like example below), considering that no variables where passed/used?



2 Answers 2


Shell features such as pathname expansion (*, ?), command lists (;, &&, ||), redirection (<, >, |,) are not implemented by supervisord that only splits the command into an array of argument strings.

The bash -c may be just a help for novice user who might be tempted to use such features in the command. For example it avoids the surprise that

command=echo foo > /tmp/bar

outputs foo > /tmp/bar instead of writing foo to /tmp/bar.

-c has little to do with variables. Any additional arguments to the bash would only be available as script arguments $0, $1, etc. in the command, but that feature has seldom any use. For example bash -c 'echo $0 $0' foo outputs foo foo.

  • 1
    Thanks, that was a very pragmatic answer, and that'll probably save me a lot of time. I, as a novice user, would make this mistake (and never think about bash -c as a solution!). Commented Sep 16, 2015 at 20:11

It is explained in the documentation:

No shell is executed by supervisord when it runs a subprocess, so environment variables such as USER, PATH, HOME, SHELL, LOGNAME, etc. are not changed from their defaults or otherwise reassigned. This is particularly important to note when you are running a program from a supervisord run as root with a user= stanza in the configuration.

To get around this issue bash -c may be used.

  • 2
    Mark, thanks for your answer but I think the other one was a more plausible scenario (while yours is not incorrect to me, I still need to choose one right answer..). Besides that, i'm also helping the new user with fewer points. Commented Sep 16, 2015 at 20:14
  • Bash does not change any of the listed environment variables. It does set SHELL, if it is not set when it is started, but leaves it to old value if it is set. So having bash -c "" in command does not fix these variables. The document tells to use the environment= configuration option to set them properly. Commented Oct 8, 2023 at 7:18

You must log in to answer this question.

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