This is the script, /home/jack/myscript.sh, which I want to run:export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26//home/jack/myapp/apache-tomcat-6.0.32/bin/./catalina.sh runThe upstart file, /etc/init/myapp.conf, that I have written:  description Myapp Server  start on runlevel [2345]  stop on runlevel [06]  respawn  respawn limit 10 5  exec `su jack -c /home/jack/myscript.sh`So, if I want to run the script as user jack, would my above configuration work? Is there a better way of doing it?
Running a bash script as a less privileged user with upstart
users;upstart
According to the Upstart cookbook, a built-in feature to run a service as a different user is planned but not implemented yet.If you have start-stop-daemon, use it.exec start-stop-daemon --start -u jack --exec /home/jack/myscript.shOtherwise, use su (as you did) or sudo. Note that start-stop-daemon always switches to the indicated user (barring errors), whereas su and sudo obey their own policy (in particular, the PAM policies on most systems).Note that in your case, you don't need the intermediate script. You can set environment variables directly from the Upstart service definition.description Myapp Server  start on runlevel [2345]  stop on runlevel [06]  respawn  respawn limit 10 5  env JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.26/  exec /home/jack/myapp/apache-tomcat-6.0.32/bin/catalina.sh run