以前一直搞的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.更新腳本的啟動順序