ubuntu系統自動配置開機啟動腳本


以前一直搞的centos配置開機啟動腳本,但是相同方法用在ubuntu系統上就不管用了,非常傷腦筋.

非常感謝  https://www.linuxidc.com/Linux/2017-09/147178.htm  http://www.linuxdiyf.com/linux/26896.html  這兩篇文章.

我第一次也是嘗試修改rc.local這個文件,但是壓根不管用.

然后嘗試第二種方法,成功了,再一次非常感謝以上兩篇文件分享的內容.

1. 創建一個shell腳本如下,以下注釋部分必須存在,不然會報錯:如下錯誤:missing LSB tags and overrides   導致腳本無法執行成功

#!/bin/sh
### BEGIN INIT INFO
# Provides: svnd.sh
# Required-start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the svnd.sh daemon
# Description: starts svnd.sh using start-stop-daemon
### END INIT INFO
sudo mount /dev/sdb /imdata/test          ##這里就是我需要開機做的事情.

2. 腳本執行執行權限;

    sudo chmod +x 你的腳本命令 

3.將腳本復制到 /etc/init.d/  下;

   cp -r 腳本名 /etc/init.d/你的腳本名

4.更新腳本的啟動順序

   cd /etc/init.d
   $ sudo update-rc.d svnd.sh defaults 90
注:其中數字95是腳本啟動的順序號,按照自己的需要相應修改即可。在你有多個啟動腳本,而它們之間又有先后啟動的依賴關系時你就知道這個數字的具體作用了。
 
5.卸載啟動腳本的方法:
  $ cd /etc/init.d
  $ sudo update-rc.d -f svnd.sh remove

 


免責聲明!

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



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