ubuntu 開機啟動shell腳本


1.創建shell啟動腳本test

 

2.將啟動腳本復制到 /etc/init.d 目錄下

3.設置腳本文件權限

sudo chmod 755 /etc/init.d/test

 

4.設置腳本啟動

sudo update-rc.d test defaults 95   //95 為啟動優先級,越小優先級越高

// 執行后輸出信息

update-rc.d: warning: /etc/init.d/test missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
Adding system startup for /etc/init.d/test ...
/etc/rc0.d/K95test -> ../init.d/test
/etc/rc1.d/K95test -> ../init.d/test
/etc/rc6.d/K95test -> ../init.d/test
/etc/rc2.d/S95test -> ../init.d/test
/etc/rc3.d/S95test -> ../init.d/test
/etc/rc4.d/S95test -> ../init.d/test
/etc/rc5.d/S95test -> ../init.d/test
4.卸載啟動腳本

sudo update-rc.d -f test remove

// 執行后輸出信息

Removing any system startup links for /etc/init.d/test ...
/etc/rc0.d/K95test
/etc/rc1.d/K95test
/etc/rc2.d/S95test
/etc/rc3.d/S95test
/etc/rc4.d/S95test
/etc/rc5.d/S95test
/etc/rc6.d/K95test

 

 

其實解決辦法就是在#!/bin/bash下面添加:

### BEGIN INIT INFO # Provides: bbzhh.com # Required-Start: $local_fs $network # Required-Stop: $local_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: tomcat service # Description: tomcat service daemon ### END INIT INFO

當然,也可以一勞永逸的:

apt-get remove insserv


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM