欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

Linux系統(tǒng)中rc.local自啟動(dòng)服務(wù)實(shí)例

本篇內(nèi)容介紹了“Linux系統(tǒng)中rc.local自啟動(dòng)服務(wù)實(shí)例”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿(mǎn)足客戶(hù)于互聯(lián)網(wǎng)時(shí)代的桃城網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

linux有自己一套完整的啟動(dòng)體系,抓住了linux啟動(dòng)的脈絡(luò),linux的啟動(dòng)過(guò)程將不再神秘。

本文中假設(shè)inittab中設(shè)置的init tree為:

/etc/rc.d/rc0.d
/etc/rc.d/rc1.d
/etc/rc.d/rc2.d
/etc/rc.d/rc3.d
/etc/rc.d/rc4.d
/etc/rc.d/rc5.d
/etc/rc.d/rc6.d
/etc/rc.d/init.d

目錄

1. 關(guān)于linux的啟動(dòng)
2. 關(guān)于rc.d
3. 啟動(dòng)腳本示例
4. 關(guān)于rc.local
5. 關(guān)于bash啟動(dòng)腳本
6. 關(guān)于開(kāi)機(jī)程序的自動(dòng)啟動(dòng)


1. 關(guān)于linux的啟動(dòng)

init是所有進(jìn)程的頂層
init讀取/etc/inittab,執(zhí)行rc.sysinit腳本
(注意文件名是不一定的,有些unix甚至?xí)⒄Z(yǔ)句直接寫(xiě)在inittab中)

rc.sysinit腳本作了很多工作:

init $PATH

config network

start swap function

set hostname

check root file system, repair if needed

check root space

....


rc.sysinit根據(jù)inittab執(zhí)行rc?.d腳本
linux是多用戶(hù)系統(tǒng),getty是多用戶(hù)與單用戶(hù)的分水嶺
在getty之前運(yùn)行的是系統(tǒng)腳本


2. 關(guān)于rc.d

所有啟動(dòng)腳本放置在 /etc/rc.d/init.d下

rc?.d中放置的是init.d中腳本的鏈接,命名格式是:

S{number}{name}

K{number}{name}

S開(kāi)始的文件向腳本傳遞start參數(shù)

K開(kāi)始的文件向腳本傳遞stop參數(shù)

number決定執(zhí)行的順序


3. 啟動(dòng)腳本示例

這是一個(gè)用來(lái)啟動(dòng)httpd的 /etc/rc.d/init.d/apache 腳本:

代碼:

#!/bin/bash

......

可以看出他接受start,stop,restart,status參數(shù)

然后可以這樣建立rc?.d的鏈接:

代碼:

cd /etc/rc.d/init.d &&

ln -sf ../init.d/apache ../rc0.d/K28apache &&

ln -sf ../init.d/apache ../rc1.d/K28apache &&

ln -sf ../init.d/apache ../rc2.d/K28apache &&

ln -sf ../init.d/apache ../rc3.d/S32apache &&

ln -sf ../init.d/apache ../rc4.d/S32apache &&

ln -sf ../init.d/apache ../rc5.d/S32apache &&

ln -sf ../init.d/apache ../rc6.d/K28apache


4. 關(guān)于rc.local

經(jīng)常使用的 rc.local 則完全是習(xí)慣問(wèn)題,不是標(biāo)準(zhǔn)。

各個(gè)發(fā)行版有不同的實(shí)現(xiàn)方法,可以這樣實(shí)現(xiàn):

代碼:

touch /etc/rc.d/rc.local

chmod +x /etc/rc.d/rc.local

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc1.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc2.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc3.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc4.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc5.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc6.d/S999rc.local

5. 關(guān)于bash啟動(dòng)腳本

/etc/profile

/etc/bashrc

~/.bash_profile

~/.bashrc

是bash的啟動(dòng)腳本

一般用來(lái)設(shè)置單用戶(hù)的啟動(dòng)環(huán)境,也可以實(shí)現(xiàn)開(kāi)機(jī)單用戶(hù)的程序,但要明確他們都是屬于bash范疇而不是系統(tǒng)范疇。

他們的具體作用介紹如下:

/bin/bash這個(gè)命令解釋程序(后面簡(jiǎn)稱(chēng)shell)使用了一系列啟動(dòng)文件來(lái)建立一個(gè)運(yùn)行環(huán)境:
/etc/profile

/etc/bashrc

~/.bash_profile

~/.bashrc

~/.bash_logout

每一個(gè)文件都有特殊的功用并對(duì)登陸和交互環(huán)境有不同的影響。

/etc/profile 和 ~/.bash_profile 是在啟動(dòng)一個(gè)交互登陸shell的時(shí)候被調(diào)用。

/etc/bashrc 和 ~/.bashrc 是在一個(gè)交互的非登陸shell啟動(dòng)的時(shí)候被調(diào)用。

~/.bash_logout 在用戶(hù)注銷(xiāo)登陸的時(shí)候被讀取

一個(gè)交互的登陸shell會(huì)在 /bin/login 成功登陸之后運(yùn)行。一個(gè)交互的非登陸shell是通過(guò)命令行來(lái)運(yùn)行的,如[prompt]$/bin/bash。一般一個(gè)非交互的shell出現(xiàn)在運(yùn)行 shell腳本的時(shí)候。之所以叫非交互的shell,是因?yàn)樗辉诿钚猩系却斎攵皇菆?zhí)行腳本程序。

6. 關(guān)于開(kāi)機(jī)程序的自動(dòng)啟動(dòng)

系統(tǒng)腳本可以放置在/etc/rc.d/init.d中并建立/etc/rc.d/rc?.d鏈接,也可以直接放置在/etc/rc.d/rc.local中。

init.d腳本包含完整的start,stop,status,reload等參數(shù),是標(biāo)準(zhǔn)做法,推薦使用。

為特定用戶(hù)使用的程序(如有的用戶(hù)需要使用中文輸入法而有的不需要)放置在~/中的bash啟動(dòng)腳本中。

========================================================================
設(shè)置系統(tǒng)自動(dòng)啟動(dòng)
在/etc/init.d/下創(chuàng)建smsafe文件

內(nèi)容:
#!/bin/bash
# chkconfig: 35 95 1
# description: script to start/stop smsafe
case $1 in
start)
sh /opt/startsms.sh
;;
stop)
sh /opt/stopsms.sh
;;
*)
echo "Usage: $0 (start|stop)"
;;
esac
更改權(quán)限
# chmod 775 smsafe

加入自動(dòng)啟動(dòng)
# chkconfig –add smsafe

查看自動(dòng)啟動(dòng)設(shè)置
# chkconfig –list smsafe

smsafe 0:off 1:off 2:off 3:on 4:off 5:on 6:off

以后可以用以下命令啟動(dòng)和停止腳本
# service smsafe start 啟動(dòng)

# service smsafe stop 停止

=======================================================================
jira 的啟動(dòng)主要依靠的是bin目錄下的catalina.sh腳本,提供了如init腳本的start,stop等參數(shù)

#!/bin/bash

#

# chkconfig: 2345 85 15

# description: jira

# processname: jira

# source function library

. /etc/init.d/functions

#下面一行比較重要,為jira的安裝路徑,沒(méi)有的話(huà),將會(huì)提示找不到文件

CATALINA_HOME="/var/www/jira"

 

RETVAL=0

start() {

echo -n $"Starting jira services: "

 

. /var/www/jira/bin/catalina.sh start

RETVAL=$?

echo

}

stop() {

echo -n $"Shutting down jira services: "

. /var/www/jira/bin/catalina.sh stop

RETVAL=$?

echo

}

case "$1" in

start)

start

;;

stop)

stop

;;

restart|reload)

stop

start

;;

status)

status jira

RETVAL=$?

;;

*)

echo $"Usage: $0 {start|stop|restart|status}"

exit 1

esac

exit $RETVAL

 

-------------------------------

保存為/etc/init.d/jira

然后利用chkconfig --add jira

OK

啟動(dòng)/etc/init.d/jira start

停止/etc/init.d/jira stop

=======================================================================

(以Websphere為例子)

1. 在/etc/rc.d/init.d目錄下新建啟動(dòng)腳本startWebsphere,鍵入以下內(nèi)容:
#!/bin/sh
/opt/WebSphere/AppServer/bin/startServer.sh server1

修改該文件的權(quán)限:
chmod 755 startWebsphere

2. 在對(duì)應(yīng)的目錄下建立軟連接(假設(shè)系統(tǒng)默認(rèn)進(jìn)入X11)
cd /etc/rc.d/rc5.d
ln -s ../init.d/startWebsphere S99startWebsphere

3. 重啟系統(tǒng)即可

=======================================================================
linux下oracle的自啟動(dòng)腳本

1.寫(xiě)一個(gè)StartOracle.sql,假設(shè)放在/目錄下
vi /StartOracle.sql加入如下兩行保存
startup
exit

2.配置/etc/rc.local
vi /etc/rc.local加入如下內(nèi)容,保存
su - oracle -c '$ORACLE_HOME/bin/lsnrctl start'
su - oracle -c '$ORACLE_HOME/bin/sqlplus "/as sysdba" @/StartOracle.sql'

3. 如果還要自動(dòng)啟動(dòng)oracle enterprise manager(em)和isqlplus可以如下配置
vi /etc/rc.local 加入:
su - oracle -c '$ORACLE_HOME/bin/emctl start dbconsole'
su - oracle -c '$ORACLE_HOME/bin/isqlplusctl start'

要知道em和isqlplus等使用的端口可以查詢(xún)文件:
$ORACLE_HOME/install/portlist.ini(以oracle 10.1.0.3為例)

=======================================================================
#root命令行下直接綁定演示:
arp -s 192.x.x.x. 00:ea:se綁定.
arp -d 刪除
arp -f 批量導(dǎo)入

“Linux系統(tǒng)中rc.local自啟動(dòng)服務(wù)實(shí)例”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

標(biāo)題名稱(chēng):Linux系統(tǒng)中rc.local自啟動(dòng)服務(wù)實(shí)例
分享網(wǎng)址:http://chinadenli.net/article42/gspjhc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷(xiāo)型網(wǎng)站建設(shè)虛擬主機(jī)品牌網(wǎng)站制作網(wǎng)站改版外貿(mào)建站定制開(kāi)發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站