Linux 起動スクリプトがユーザーのホームディレクトリのスクリプトを実行しない

Linux 起動スクリプトがユーザーのホームディレクトリのスクリプトを実行しない

システムの起動時にラズベリーパイでスクリプトを実行したい。そのために、/etc/init.d 内にスクリプトを作成し、それを /etc/rc2.d にリンクしました。

これは init.d 内のスクリプトです:


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



#Switch case fuer den ersten Parameter
case "$1" in
    start)
        #Aktion wenn start aufgerufen wird
        /home/thomas/applications/autostart/autostart.sh
        ;;

    stop)
        #Aktion wenn stop aufgerufen wird
        echo "nope"
        ;;

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

exit 0

そして、これが次の内容です/home/thomas/applications/autostart/autostart.sh:


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

/etc/init.d のスクリプト内の start コマンドを次の行に変更すると、touch コマンドが実行されます。


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

では、なぜ別のスクリプトが実行されないのでしょうか?

よろしくお願いします、マクファーレン

答え1

示したものがまさにその通りだと仮定すると、書式エラーがあるためスクリプトは動作しません。シェバン行の!#との間にはスペースを入れないでください。/bin/sh

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

関連情報