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 want a script on my raspberry pi to run when the system boots. That's why I've created a script inside /etc/init.d that is linked in /etc/rc2.d

This is the script inside init.d:

#! /bin/sh
# Provides:          Scriptname
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Kurze Beschreibung
# Description:       Bechreibung

#Switch case fuer den ersten Parameter
case "$1" in
        #Aktion wenn start aufgerufen wird

        #Aktion wenn stop aufgerufen wird
        echo "nope"

        #Aktion wenn restart aufgerufen wird
        echo "nope"
        #Default Aktion wenn start|stop|restart nicht passen
        echo "(start|stop|restart)"

exit 0

And this is the content of /home/thomas/applications/autostart/

#! /bin/sh
touch /home/thomas/kater

when i change the start command inside the script in /etc/init.d to the following lines, the touch command gets executed:

        #Aktion wenn start aufgerufen wird
        touch /home/thomas/kater

So why doesn't it execute the seperate script?

Thanks in advance, McFarlane

share|improve this question
up vote 1 down vote accepted

Assuming what you have shown is exactly what you have, the script won't work because you have a formatting error. There should be no space between !# and /bin/sh in the shebang line:

touch /home/thomas/kater
share|improve this answer
you are right. but even without the space the touch command is not beeing executed. – McFarlane Mar 2 '14 at 18:47
@McFarlane is the script executable? Please edit your question and add the output of ls -l /home/thomas/applications/autostart/ – terdon Mar 2 '14 at 18:49
the problem was indeed the wrong #!/bin/sh line. I had it wrong in two files that's why it didn't work the first time. – McFarlane Mar 4 '14 at 12:32

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.