您好,登錄后才能下訂單哦!
小編給大家分享一下ubuntu系統(tǒng)中/etc/rc.local和/etc/init.d/rc.local的區(qū)別有哪些,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
/etc/init.d/rc.local
#! /bin/sh ### BEGIN INIT INFO # Provides: rc.local # Required-Start: $all # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: # Short-Description: Run /etc/rc.local if it exist ### END INIT INFO PATH=/sbin:/usr/sbin:/bin:/usr/bin . /lib/init/vars.sh . /lib/lsb/init-functions do_start() { if [ -x /etc/rc.local ]; then [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" /etc/rc.local ES=$? [ "$VERBOSE" != no ] && log_end_msg $ES return $ES fi } case "$1" in start) do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac
從注釋可以看出該腳本運(yùn)行在2 3 4 5的啟動(dòng)級(jí)別,只能處理start的參數(shù),然后執(zhí)行start,如果有/etc/rc.local文件的話則執(zhí)行/etc/rc.local。如果要把開(kāi)機(jī)啟動(dòng)的程序放/etc/init.d/rc.local文件里,記住千萬(wàn)別一股腦寫(xiě)文件最后面就行了,因?yàn)樵赾ase語(yǔ)句塊里腳本就會(huì)退出。
/etc/rc.local
#!/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
這個(gè)腳本里面基本沒(méi)有內(nèi)容,就是寫(xiě)個(gè)模板讓你放開(kāi)機(jī)自啟動(dòng)程序的。把你的程序?qū)懺趀xit 0行的前面就行了。
所以要添加開(kāi)機(jī)啟動(dòng)項(xiàng),只需在/etc/rc.local文件中添加就行了。
ubuntu的啟動(dòng)級(jí)別:
0 關(guān)機(jī)
1 單用戶
2-5 多用戶圖形界面
6 重啟
對(duì)應(yīng)每個(gè)啟動(dòng)級(jí)別,/etc/目錄下都對(duì)應(yīng)一個(gè)像/etc/rc5.d/這樣的目錄,下面是一些腳本,這些腳本基本都是對(duì)應(yīng)/etc/init.d/目錄下的軟鏈接,命名里面的數(shù)字代表優(yōu)先級(jí),啟動(dòng)時(shí)這些腳本都會(huì)執(zhí)行一遍。
備注:我的系統(tǒng)為ubuntu 15.04
以上是“ubuntu系統(tǒng)中/etc/rc.local和/etc/init.d/rc.local的區(qū)別有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。