title: Python script as daemon in ubuntu
body: <p>I created a daemon to run a python script. but it stops whenever i logout from my ubuntu machine. </p>
  
  <pre><code>DAEMON=sudo python /var/www/some_dir/my_python.py
  ARGS=/var/www/some_dir/my_python.py
  PIDFILE=/var/www/some_dir/my_python.pid
  
  test -x $DAEMON || exit 0
  
  #set -e
  
  case "$1" in
  start)
      echo -n "Starting $DESC: "
      start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON &amp;
      echo "$NAME."
      ;;
  stop)
      echo -n "Stopping $DESC: "
      start-stop-daemon --stop --pidfile $PIFDILE --exec $DAEMON
      echo "$NAME."
      ;;
  restart|force-reload)
      echo -n "Restarting $DESC: "
      start-stop-daemon --stop --pidfile $PIDFILE --exec $DAEMON
      sleep 1
      start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON &amp;
      echo "$NAME."
      ;;
  *)
      N=/etc/init.d/$NAME
      echo "Usage: $N {start|stop|restart|force-reload}" &gt;&amp;2
      exit 1
      ;;
  esac
  exit 0
  </code></pre>
  
  <p>can anyone tell me how can i do it.</p>