rc.local腳本
rc.local腳本是一個ubuntu開機后會自動執(zhí)行的腳本,我們可以在該腳本內(nèi)添加命令行指令。該腳本位于/etc/路徑下,需要root權(quán)限才能修改。
該腳本具體格式如下:
#!/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
注意: 一定要將命令添加在 exit 0之前
如何給ubuntu添加一個開機啟動腳本
1,新建個腳本文件new_service.sh
#!/bin/bash# command content exit 0
2,設(shè)置權(quán)限
sudo chmod 755 new_service.sh
3,把腳本放置到啟動目錄下
sudo mv new_service.sh /etc/init.d/
4,將腳本添加到啟動腳本
執(zhí)行如下指令,在這里90表明一個優(yōu)先級,越高表示執(zhí)行的越晚
cd /etc/init.d/sudo update-rc.d new_service.sh defaults 90
移除Ubuntu開機腳本
sudo update-rc.d -f new_service.sh remove
總結(jié)
以上就是這篇文章的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。
新聞熱點
疑難解答
圖片精選