日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線(xiàn)溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
CentOS的SystemVinit啟動(dòng)腳本

CentOS系統(tǒng)本身自帶了說(shuō)明,在/usr/share/doc/initscripts-(*)/sysvinitfiles,內(nèi)容如下:所有System V init腳本都命名為/etc/rc.d/init.d/,其中是服務(wù)的名稱(chēng)。必須沒(méi)有“.init”后綴。

為榕江等地區(qū)用戶(hù)提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及榕江網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)、榕江網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

示例腳本:

#!/bin/bash
#
# /etc/rc.d/init.d/ 
#
#  
#  
#
#   # of the file to the end of the tags section must begin with a # # character. After the tags section, there should be a blank line. # This keeps normal comments in the rest of the file from being # mistaken for tags, should they happen to fit the pattern.> # Source function library. . /etc/rc.d/init.d/ functions  local   shell functions used by the code that follows>

case "$1" in
   start)
       echo -n "Starting    services: " 
       
  
   function>        touch /var/lock/subsys/
   
        ;;    stop)        
    echo -n 
    "Shutting down    services: "         
    
     function>        rm -f /var/lock/subsys/
     
          ;;    status)        
      
       in free-form format,        perhaps with the status 
       function>    ;;    restart)        
       
        $0 stop; 
        $0 start>    ;;    reload)        
        
         kill -HUP or by restarting the daemons, possibly with        
         $0 stop; 
         $0 start>    ;;    probe)        
         
          then it should determine whether        or not the service needs to be restarted or reloaded (or        whatever) 
          in order to activate any changes 
          in the configuration        scripts. It should 
          print out a list of commands to give to        
          $0; see the description under the probe tag below.>    ;;    *)        
          echo 
          "Usage:    {start|stop|status|reload|restart[|probe]"         
          exit 1    ;; 
          esac 
         
        
       
      
     
    
   
  

注意:重啟和重載功能可以(通常)組合成一個(gè)測(cè)試,

vis:

restart|reload)

不禁止您添加其他命令; 列出您打算以交互方式使用到使用消息的所有命令。

/etc/rc.d/init.d/functions函數(shù)

daemon [+/-nicelevel] program [arguments] [&]

如果守護(hù)程序尚未運(yùn)行,則啟動(dòng)該守護(hù)程序。還有其他一些有用的東西,例如,如果守護(hù)進(jìn)程意外終止,則保留守護(hù)進(jìn)程。

killproc program [signal]

向程序發(fā)送信號(hào); 默認(rèn)情況下,它發(fā)送一個(gè)SIGTERM,如果進(jìn)程沒(méi)有死,它會(huì)在幾秒鐘后發(fā)送一個(gè)SIGKILL。

如果找到pid文件,它還會(huì)嘗試刪除它。

pidofproc program

試圖找到一個(gè)程序的pid; 檢查可能的pidfiles,使用pidof程序,甚至使用ps。主要用于此文件中的其他函數(shù),但也可用于腳本。

status program

打印狀態(tài)信息。假設(shè)程序名稱(chēng)與servicename相同。

Tags.

# chkconfig:          

必須。是默認(rèn)情況下應(yīng)啟動(dòng)服務(wù)的級(jí)別列表。和是優(yōu)先級(jí)編號(hào)。例如:

# chkconfig:2345 20 80有關(guān)詳細(xì)信息,請(qǐng)閱讀“man chkconfig”。

除非有一個(gè)非常好的,顯性相反的原因,應(yīng)該等于 100 –

# description: 
  

必須。幾行描述,繼續(xù)使用”字符。以下行中的初始注釋和后續(xù)空格將被忽略。

# description[ln]:  

可選。應(yīng)將描述翻譯成指定的語(yǔ)言。

# processname:

可選,允許多個(gè)條目。對(duì)于腳本啟動(dòng)的每個(gè)進(jìn)程名稱(chēng),應(yīng)該有一個(gè)進(jìn)程名稱(chēng)條目。例如,samba服務(wù)啟動(dòng)兩個(gè)守護(hù)進(jìn)程:

#processname:smdb
  #processname:nmdb

# config:

可選,允許多個(gè)條目。對(duì)于守護(hù)程序使用的每個(gè)靜態(tài)配置文件,請(qǐng)使用單個(gè)條目。例如:

# config: /etc/httpd/conf/httpd.conf
  # config: /etc/httpd/conf/srm.conf

可選)如果服務(wù)器將自動(dòng)重新加載配置文件(如果已更改),則可以在行中附加“autoreload”一詞:

# config: /etc/foobar.conf autoreload

#pidfile:

可選,允許多個(gè)條目。使用就像配置條目一樣,除了它指向pidfiles。假設(shè)pidfiles僅在進(jìn)程創(chuàng)建時(shí)更新,而不是更晚。該文件的第一行應(yīng)該是PID的ASCII表示; 終止換行符是可選的。不檢查除第一行以外的任何行。

#project: true

可選,使用IN PLACE的processname,config和pidfile。如果存在,則可以通過(guò)運(yùn)行以下命令來(lái)實(shí)現(xiàn)正確的重新加載 – 如果必要的循環(huán):

command = $(/ etc / rd.d / init.d / SCRIPT probe)
[ -  n“$ command”] && /etc/rc.d/init.d/SCRIPT $ command

其中SCRIPT是服務(wù)的sysv init腳本的名稱(chēng)。

作為示例,需要執(zhí)行復(fù)雜處理的腳本可以返回“run /var/tmp/

請(qǐng)注意,如果不需要執(zhí)行任何操作使服務(wù)與其配置文件同步,則probe命令應(yīng)該只是“exit 0”。

需要注意以下幾點(diǎn):

1、# chkconfig和# description不能少,必須寫(xiě)。

2、chkconfig的 為啟動(dòng)優(yōu)先級(jí),在man中查詢(xún)不到,一般end…不用理解,直接100-start…即可。start為開(kāi)始的順序,一般系統(tǒng)從小執(zhí)行到大,數(shù)值任意,這個(gè)對(duì)于依賴(lài)啟動(dòng)有很大的幫助,比如控制先啟動(dòng)某個(gè)服務(wù),再啟動(dòng)某個(gè)服務(wù)。以下是查詢(xún)?cè)O(shè)置后的命令:

# 查詢(xún)啟動(dòng)級(jí)別
chkconfig --list 
  
   # 查詢(xún)啟動(dòng)順序 grep chkconfig /etc/rc.d/init.d/
   
  

文章題目:CentOS的SystemVinit啟動(dòng)腳本
文章位置:http://www.dlmjj.cn/article/dpsedss.html