Linux 시작 스크립트가 사용자 홈 디렉토리에서 스크립트를 실행하지 않습니다.

Linux 시작 스크립트가 사용자 홈 디렉토리에서 스크립트를 실행하지 않습니다.

시스템이 부팅될 때 라즈베리 파이의 스크립트가 실행되기를 원합니다. 그래서 /etc/rc2.d에 링크된 /etc/init.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의 스크립트 내에서 시작 명령을 다음 줄로 변경하면 touch 명령이 실행됩니다.


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

그렇다면 왜 별도의 스크립트를 실행하지 않습니까?

미리 감사드립니다, McFarlane

답변1

표시된 내용이 정확히 같다고 가정하면 형식 오류가 있기 때문에 스크립트가 작동하지 않습니다. shebang 줄 사이에 !#공백 이 있어서는 안 됩니다 ./bin/sh

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

관련 정보