在/etc/init.d/目錄下新建乙個服務指令碼檔案。在終端輸入並回車pi@raspberry:~ $ sudo nano /etc/init.d/testboot在空白檔案中輸入以下內容:
ctrl+o儲存,ctrl+x退出。設定指令碼可執行許可權:pi@raspberry:~ $ sudo chmod 777 /etc/init.d/testboot最後將該指令碼作為服務設定開機自動載入:pi@raspberry:~ $ sudo update-rc.d testboot defaults 開機執行。#!/bin/sh
#/etc/init.d/testboot
### begin init info
# provides:testboot
# required-start:$remote_fs $syslog
# required-stop:$remote_fs $syslog
# default-start:2 3 4 5
# default-stop:0 1 6
# short-description: testboot
### end init info
case "$1" in
start)
su pi -c "exec ~/testboot.sh"
;;stop)
;;*)
echo "usage: service testboot start|stop"
exit 1
;;esac
exit 0
sudo reboot 重啟測試。
作為linux服務隨開機啟動
在 etc rc.d init.d中編寫lan monitor可執行指令碼如下 bin bash chkconfig 235 98 98 description start or stop lan monitor start stop case 1 in start start stop stop ...
將Memcached作為服務自動啟動
通常 啟動memcache的伺服器端的命令為 usr local bin memcached d m 256 u root l 127.0.0.1 p 12000 c 2048 p tmp memcached.pid 在 etc rc.d rc.local中加入一行,上面命令 最好選擇是 nobod...
ubuntu 設定服務並開機啟動
1.新建檔案hello.service unit description hello after network.target service type forking execstart startup.sh install wantedby multi user.target2.移動hello....