특정 서비스로 프로그램을 등록하려면

 

 

1. init script 파일 생성

아래와 같은 형식으로 등록 (이름은 맞게 수정)

cat > /etc/init.d/test

#! /bin/sh

 

export HOME

case "$1" in 

     start)

         echo "Starting test program"

         /usr/bin/python  /home/pi/test.py  2>&1 &

     ;;

     stop)

         echo "Stopping test program"

         PID=`ps auxwww | grep test.py | head -l | awk '{print $2}'`

     ;;

     *)

         echo "Usage: /etc/init.d/test {start|stop}"

         exit 1

     ;;

     esac

     exit 0

 

 

2. init script 파일을 실행파일(+x)로 변경

 

    chmod +x  /etc/init.d/test

 

3. 새로운 init script 파일을 등록

 

    update-rc.d    test   defaults

'RaspBerry PI' 카테고리의 다른 글

raspbian update  (0) 2019.06.14
os 버전  (0) 2019.06.14
startup시 자동 프로그램 시작  (0) 2019.06.14
s/w 설치, 삭제  (0) 2019.06.14
화면 screen capture  (0) 2019.06.14

+ Recent posts