0

I do not understand this error: start-stop-daemon: option --exec requires an argument

I am very new to the init.d world and have only just got my script going using service calls, I just want to get this script working, it starts on boot but failed because of this error any help? (any suggestions or rewrites are welcome even if not related to my issue)

Here is my script:

#!/bin/bash
# shell script to ...

#set the full path to the programs we need to use
NTOP=/opt/bash_scripts/start-up-superscript &
KILLALL=/usr/bin/killall

case "$1" in
        start)

                   echo "Starting SDD Install..."
                start-stop-daemon --start --quiet --oknodo --exec $NTOP
                ;;
        stop)
                #kill ntop
                echo "Stopping SSD..."
                $KILLALL ntop           
                ;;
        restart)
                $0 stop
                $0 start
                ;;
        status)
                ;;
        *)
                echo "Usage: $0 {start|stop|restart|status}"
                ;;
esac
TPS
  • 2,481
TheHidden
  • 808
  • 1
    I think that the form:

    NTOP=/opt/bash_scripts/start-up-superscript & must be:

    `NTOP=/opt/bash_scripts/start-up-superscript`
    
    – LilloX Dec 07 '15 at 10:23
  • Yea i changed that and added the & here: start-stop-daemon --start --quiet --oknodo --exec $NTOP & ... this now works fine... BUT I cannot kill the process :/ ?? any ideas why it is not killing the process? – TheHidden Dec 07 '15 at 10:26
  • try $KILLALL $NTOP – LilloX Dec 07 '15 at 10:28
  • @LilloX root@linaro-alip:~# service start-up-ssd stop Stopping SSD... /opt/bash_scripts/start-up-ssd: no process found

    I can kill it if I type /bin/bash ... but this would obviously kill all bash scripts... :/ dunno what to do (I just tried your suggestion but the out put of NTOP is /bin/bash /opt/bash_scripts/start-up-ssd)

    – TheHidden Dec 07 '15 at 10:32
  • But $NTOP has not the value /opt/bash_scripts/start-up-superscript ? So you want to kill a process run by start-up-superscript? if you do a start and then do a ps -ef did you find "/opt/bash_scripts/start-up-superscript"? – LilloX Dec 07 '15 at 10:37
  • @LilloX root 1629 1 1 11:54 ttymxc1 00:00:00 /bin/bash /opt/bash_scripts/star.... – TheHidden Dec 07 '15 at 10:55
  • Ok, I will make an answer with some modifications to your script. – LilloX Dec 07 '15 at 11:36

1 Answers1

1

I quote here the changes in the comments and shared editing for the kill process. As for the start you need to remove the & from the definition of the name of the service to start.

In order to identify the process to stop, since in the launch it is added the interpreter, it is convenient to use a PID. So your script may be modify as:

#!/bin/bash
# shell script to ...
set -e

#set the full path to the programs we need to use
NTOP=/opt/bash_scripts/start-up-superscript
PIDFILE=/var/run/start-up-superscript.pid
case "$1" in
        start)
            echo "Starting SDD Install..."
            start-stop-daemon --start --quiet --oknodo --exec $NTOP --pidfile $PIDFILE -m
            ;;
        stop)
            #kill ntop
            echo "Stopping SSD..."
            start-stop-daemon --stop --quiet --pidfile $PIDFILE
            ;;
        restart)
            $0 stop
            $0 start
            ;;
        status)
            ;;
        *)
                echo "Usage: $0 {start|stop|restart|status}"
                ;;
esac

In this way the whole process start and stop should work as you want.

LilloX
  • 1,226