Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to get a starter script (for a ruby gem called ar_sendmail) working in /etc/init.d/ar_sendmail:

#! /bin/sh

echo "in /etc/init.d/ar_sendmail"
DAEMON_OPTS="-e production -d --batch-size 100 --delay 150"

test -x $DAEMON || exit 0
set -e

case "$1" in
        echo -n "Starting $DESC: "
        start-stop-daemon -d $DIR --start --quiet --pidfile $PID_FILE \
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        echo -n "Stopping $DESC: "
        kill -TERM `cat $PID_FILE`        
    rm $PID_FILE
        echo "$NAME."
        echo -n "Restarting $DESC: "
        kill -TERM `cat $PID_FILE`        
    rm $PID_FILE
        sleep 1
        start-stop-daemon -d $DIR --start --quiet --pidfile \
                $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
            echo "Usage: $N {start|stop|restart|reload}" >&2
            exit 1   

    exit 0

It's blowing up on the start-stop-daemon line, saying "start-stop-daemon: not found". But, when i plug the values into that line manually, and run it on the command line, it works.

My first thought was it was the shebang line but #! /bin/sh should be right shouldn't it? It's definitely the right folder and what i use in my other /etc/init.d scripts.

My second thought was that it's sudo related: i'd been testing start-stop-daemon in non-sudo and running /etc/init.d/ar_sendmail in sudo mode. But, i can run start-stop-daemon fine with sudo as well.

Kind of stumped, any ideas?

share|improve this question
Please don't cross-post. – Dennis Williamson Mar 8 '11 at 11:40
up vote 5 down vote accepted

There's your problem.

You're clobbering your PATH variable so it can't find start-stop-daemon in /sbin

Try using:


Or something similar instead.

share|improve this answer
aaah! of course. Thanks matt. – Max Williams Mar 9 '11 at 10:55
@MaxWilliams: Any reason this answer isn't marked as accepted? – daramarak Oct 21 '15 at 14:21
@daramarak neglect on my part. Marked now, thanks for the prod. – Max Williams Oct 21 '15 at 15:18

Your Answer


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.