mxwl

树莓派3添加自启动

 

在 /etc/init.d 目录下创建文件 my-init,编辑文件。(启动执行的脚本位于 /home/pi/init.sh)

 1 #!/bin/sh
 2 #/etc/init.d/my-init
 3 
 4 ### BEGIN INIT INFO
 5 # Provides:          get-ip-address
 6 # Required-Start:    $remote_fs $syslog
 7 # Required-Stop:     $remote_fs $syslog
 8 # Default-Start:     2 3 4 5
 9 # Default-Stop:      0 1 6
10 # Short-Description: get-ip-address
11 # Description: This service is used to start my get-ip-address
12 ### END INIT INFO
13 
14 
15 case "$1" in
16     start)
17         echo "Starting my init"
18         nohup /home/pi/init.sh &
19          ;;
20     stop)
21         echo "Stop"
22         #kill $( ps aux | grep -m 1 \'python /home/pi/get-ip-address.py\' | awk \'{ print $2 }\')
23         ;;
24 
25     *)
26         echo "Usage: service get-ip-address start|stop"
27         exit 1
28         ;;
29 esac
30 exit 0

 sudo update-rc.d my-init defaults

 

分类:

技术点:

相关文章: