I've created a script in /etc/init/mms-agent.conf :start on runlevel [2345]stop on runlevel [06]exec /usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1service mms-agent start/stop work fine, but i'd like to start this service with the user mmsWhen I try to change the script as following :exec su mms -c /usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1I get 3 process running instead of 1 expected (su, bash + my python script):mms       8864  0.0  0.2  37816  1332 ?        Ss   22:30   0:00 su mms -c /usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1mms       8865  0.0  0.2  11452  1196 ?        S    22:30   0:00 bash -c /usr/bin/env python /home/mms/mms-agent/agent.py >> /home/mms/agent.log 2>&1mms       8866  4.0  1.8  54672 10640 ?        Sl   22:30   0:00 python /home/mms/mms-agent/agent.pyWhat does that mean ? What is the best way to start a script with a user different than root ?ThanksPS : exec start-stop-daemon --start -u mms --exec /usr/bin/env python /home/mms/mms-agent/agent.pydoesn't work, I got no error but the process isn't started.
linux launch script /etc/init with a specific user
su;services;upstart
When you exec su, the shell is replaced with the su process.  su then forks and execs bash.  bash sets up the output redirection and then forks and execs env.  env searches PATH, finds python and execs it.  So you're left with three processes, 1) su, waiting for bash to exit, 2) bash, waiting for python (previously env) to exit, and 3) python, which is busily running your script.There is nothing wrong with this.  su is the Unix time-honored way to temporarily switch users, so that's what you should be using.  Similarly, the way to run a command line is to use a shell, so su runs bash and lets bash handle it.  Again, this follows the general Unix toolbox approach, letting the shell do what the shell is good at, and not reinventing shell command line and PATH search functionality in another application.Also, since bash is already doing the PATH search, you can drop the use of env and invoke python directly.