- 把要執行的python檔案放到 /usr/local/sbin/
- 建立開機服務程式,例如: sudo nano /etc/init.d/example
- 設定執行權限:sudo chmod 755 example
- 執行開機設定:sudo update-rc.d example defaults
- 重新開機
example:
#! /bin/sh
# /etc/init.d/example
case "$1" in
start)
echo "Starting example"
# run application you want to start
python /usr/local/sbin/example.py &
;;
stop)
echo "Stopping example"
# kill application you want to stop
killall python
;;
*)
echo "Usage: /etc/init.d/example{start|stop}"
exit 1
;;
esac
exit 0
原始網站
沒有留言:
張貼留言