Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to run my python script as a service... But I'm getting this error when I call sudo update-rc.d mylistener start:

Use of uninitialized value $ARGV[1] in pattern match (m//) at /usr/sbin/update-rc.d line 192.

update-rc.d: error: expected NN after start

Here is my init script mylistener:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          mylistener
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     S
# Default-Stop:      0 6
# Short-Description: This is the description.
# Description:       This is the description.
### END INIT INFO

DAEMON=/srv/example.org/public/env/bin/python
ARGS=/srv/example.org/public/my_listener.py
PIDFILE=/srv/example.org/my_listener.pid

case "$1" in
  start)
    echo "starting server"
    /sbin/start-stop-daemon --start --pidfile $PIDFILE \
        --user www-data --group www-data \
        -b --make-pidfile \
        --chuid www-data \
        --exec $DAEMON $ARGS
    ;;
  stop)
    echo "stopping server"
    /sbin/start-stop-daemon --stop --pidfile $PIDFILE --verbose
    ;;
  *)
    echo "Useage: /etc/init.d/mylistener {start|stop}"
    exit 1
    ;;
esac

exit 0

Can anyone see where I'm going wrong? This is running on a debian server.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Try this:

sudo update-rc.d mylistener start 20 2 3 4 5 . stop 80 0 1 6 .

it means that your init script will be start at 20th order, runlevel 2345 and stop at 80th priority, runlevel 016.

or simple is:

sudo update-rc.d mylistener defaults
share|improve this answer
    
If I run sudo update-rc.d mylistener start 20 3 5 . I get Adding system startup for /etc/init.d/mylistener but I cannot see where it's running and it doesn't appear to run either. –  ing0 Oct 25 '11 at 10:53
    
What happen if you run /etc/init.d/mylistener start and verify it is running with ps -ef | grep mylistener? –  quanta Oct 25 '11 at 10:57
    
james 27380 20728 0 12:00 pts/1 00:00:00 grep mylistener –  ing0 Oct 25 '11 at 11:01
    
Ah thanks, it's working now :) I must have not tried starting it like that! –  ing0 Oct 25 '11 at 11:05
    
I've just noticed that by running it without update-rc.d, it (obviously) doesn't auto run on boot. How can I set it up to do this? –  ing0 Oct 27 '11 at 14:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.