1.創(chuàng)建一個(gè)腳本
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
2.在exit 0之前寫(xiě)好shell腳本
3.給腳本增加執(zhí)行權(quán)限
sudo chmod +x test.sh
4.在啟動(dòng)目錄下創(chuàng)建軟鏈接
sudo ln -s test.sh /etc/init.d/
5.添加自啟動(dòng)
cd /etc/init.d/
sudo update-rc.d test.sh defaults 90
說(shuō)明90為優(yōu)先級(jí)单默,數(shù)字越大,啟動(dòng)越晚忘瓦。
6.放棄開(kāi)機(jī)啟動(dòng)
sudo update-rc.d -f test.sh remove