I have this startup script, when i launch i have the execution done by username: root, instead of username: sun.How can i tell the start_daemon to execute it as username : sun not root?$ ps aux | grep pythonroot       950  0.1  0.2 171132 18936 ?        S    05:35   0:00 /usr/bin/python /var/tmp/mp.pyroot@nson:/etc/rc0.d# cat K20mp #! /bin/shPATH=/bin:/usr/bin:/sbin:/usr/sbinDAEMON=/var/tmp/mp.shPIDFILE=/var/run/mp.pidtest -x $DAEMON || exit 0. /lib/lsb/init-functionscase $1 in  start)     log_daemon_msg Starting mp     start_daemon -p $PIDFILE $DAEMON --user sun --chuid sun     log_end_msg $?   ;;  stop)     log_daemon_msg Stopping mp     killproc -p $PIDFILE $DAEMON     PID=`ps x |grep mp.py | head -1 | awk '{print $1}'`     kill -9 $PID            log_end_msg $?   ;;  force-reload|restart)     $0 stop     $0 start   ;;  status)     status_of_proc -p $PIDFILE $DAEMON atd && exit 0 || exit $?   ;; *)   echo Usage: /etc/init.d/atd {start|stop|restart|force-reload|status}   exit 1  ;;esacexit 0EDIT: Reference not workinghttp://man.he.net/man8/start-stop-daemonhttp://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html
Daemon - how to tell the start daemon to execute this daemon as different username than root?
boot;startup;daemon;upstart;startproc
--user and --chuid works but has to be used with start-stop-daemon.Example: As root user if now execute: /etc/init.d/PythonGUI start it execute as username: sun#! /bin/shPATH=/sbin:/usr/sbin:/bin:/usr/binDESC=Python GUI - ServerNAME=PythonGUI.shDAEMON=/var/tmp/$NAMEDAEMON_ARGS=--options argsPIDFILE=/var/run/$NAME.pidSCRIPTNAME=/etc/init.d/PythonGUI[ -x $DAEMON ] || exit 0[ -r /etc/default/$NAME ] && . /etc/default/$NAME. /lib/init/vars.sh. /lib/lsb/init-functionsdo_start() {    start-stop-daemon --start --quiet --user sun --pidfile $PIDFILE --chuid sun --exec $DAEMON --test > /dev/null \        || return 1    start-stop-daemon --start --quiet --user sun --pidfile $PIDFILE --chuid sun --exec $DAEMON -- \        $DAEMON_ARGS \        || return 2}do_stop() {    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME    RETVAL=$?    [ $RETVAL = 2 ] && return 2    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON    [ $? = 2 ] && return 2        rm -f $PIDFILE    return $RETVAL}do_reload() {    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME    return 0}case $1 in  start)    [ $VERBOSE != no ] && log_daemon_msg Starting $DESC $NAME    do_start    case $? in        0|1) [ $VERBOSE != no ] && log_end_msg 0 ;;        2) [ $VERBOSE != no ] && log_end_msg 1 ;;    esac    ;;  stop)    [ $VERBOSE != no ] && log_daemon_msg Stopping $DESC $NAME    do_stop    case $? in        0|1) [ $VERBOSE != no ] && log_end_msg 0 ;;        2) [ $VERBOSE != no ] && log_end_msg 1 ;;    esac    ;;  status)    status_of_proc $DAEMON $NAME && exit 0 || exit $?    ;;  restart|force-reload)    log_daemon_msg Restarting $DESC $NAME    do_stop    case $? in      0|1)        do_start        case $? in            0) log_end_msg 0 ;;            1) log_end_msg 1 ;; # Old process is still running            *) log_end_msg 1 ;; # Failed to start        esac        ;;      *)        log_end_msg 1        ;;    esac    ;;  *)    echo Usage: $SCRIPTNAME {start|stop|status|restart|force-reload} >&2    exit 3    ;;esac:EDIT:update-rc.d apache2 start 20 2 3 4 . start 30 5 . stop 80 0 1 6 .priority 20 (it can be 30, 80 etc)runlevels for start / stopRunlevels are logical groups of tasks. Traditionally you have five run levels.0 boot1 single user 2 not used3 multiuser4 not used 5 gui6 reboot 