国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務器 > Web服務器 > 正文

ubuntu系統中/etc/rc.local和/etc/init.d/rc.local的區別詳解

2024-09-01 13:52:42
字體:
來源:轉載
供稿:網友

前言

我們在ubuntu下要把一個程序加入開機啟動,一般可以通過修改rc.local來完成,但ubuntu下有兩個rc.local文件。分別是/etc/rc.local和/etc/init.d/rc.local。可以看一下兩個文件的內容找到他倆的關系:

/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 INFOPATH=/sbin:/usr/sbin:/bin:/usr/bin. /lib/init/vars.sh. /lib/lsb/init-functionsdo_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

從注釋可以看出該腳本運行在2 3 4 5的啟動級別,只能處理start的參數,然后執行start,如果有/etc/rc.local文件的話則執行/etc/rc.local。如果要把開機啟動的程序放/etc/init.d/rc.local文件里,記住千萬別一股腦寫文件最后面就行了,因為在case語句塊里腳本就會退出。

/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

這個腳本里面基本沒有內容,就是寫個模板讓你放開機自啟動程序的。把你的程序寫在exit 0行的前面就行了。

所以要添加開機啟動項,只需在/etc/rc.local文件中添加就行了。

ubuntu的啟動級別:

  0   關機

  1   單用戶

  2-5  多用戶圖形界面

  6   重啟 

對應每個啟動級別,/etc/目錄下都對應一個像/etc/rc5.d/這樣的目錄,下面是一些腳本,這些腳本基本都是對應/etc/init.d/目錄下的軟鏈接,命名里面的數字代表優先級,啟動時這些腳本都會執行一遍。

備注:我的系統為ubuntu 15.04

總結

好了,以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對VEVB武林網的支持。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大理市| 增城市| 商南县| 鄂尔多斯市| 山东省| 阿勒泰市| 绵竹市| 涪陵区| 鄢陵县| 安庆市| 梧州市| 涿州市| 行唐县| 原平市| 宝应县| 界首市| 佳木斯市| 沂源县| 东光县| 阿坝| 荔波县| 桃园市| 江永县| 陕西省| 福贡县| 万载县| 凤冈县| 澳门| 江西省| 大新县| 康乐县| 昌黎县| 封开县| 湄潭县| 靖宇县| 信丰县| 乐山市| 宽甸| 安福县| 新蔡县| 馆陶县|