Supervisor config user option in program section
You can use directory option.
"When supervisord daemonizes, switch to this directory. This option can include the value"
[program:testpro]
command=python /path/to/myfile.py
directory=/path/to/
user=bob ; set the user to bob
redirect_stderr=true
stdout_logfile=/path/to/log
numproces=1
autostart=true
I have solved this problem:
add environment
option in program section:
environment=HOME="/home/bob",USER="bob"
See Supervisor doc - Subprocess Environment:
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. Unlike cron, supervisord does not attempt to divine and override “fundamental” environment variables like USER, PATH, HOME, and LOGNAME when it performs a setuid to the user defined within the user= program config option. If you need to set environment variables for a particular program that might otherwise be set by a shell invocation for a particular user, you must do it explicitly within the environment= program config option. An example of setting these enviroment variables is as below.
[program:apache2]
command=/home/chrism/bin/httpd -c "ErrorLog
/dev/stdout" -DFOREGROUND user=chrism
environment=HOME="/home/chrism",USER="chrism"