1. chkconfig鑴氭湰鏍煎紡錛?/div> #!/bin/sh
#chkconfig 2345 55 45
#涓婇潰涓哄浐瀹氭牸寮忥細2345 琛ㄧず榪愯綰у埆錛?5琛ㄧず寮鏈烘墽琛岄『搴忥紝45涓哄叧鏈洪『搴?
#description錛歵his is just a demo of chkconfig script
case “$1” in
start)
<start-script>
;;
Stop)
<stop-script>
;;
Status)
Echo <the information you want to display>
;;
*)
Echo “the usage of the script”
Case
2. 鐒跺悗灝嗚剼鏈繚瀛?騫惰祴浜堟墽琛屾潈闄?鍐嶅鍒跺埌/etc/init.d鐩綍
#chmod a+x <myscript>
#copy <myscript> /etc/init.d
3. 浣跨敤chkconfig鍛戒護娣誨姞鎴愭湇鍔?
#chkconfig --add <myscript>
#chkconfig --level 35 <myscript > on
#chkconfig --list <myscript>
4. 鐒跺悗灝卞彲浠ラ氳繃service鍛戒護綆$悊浜?
#service <myscript> start | stop | status
5. 涓嬮潰鏄垜鍐欑殑涓涓疄渚嬭剼鏈紝澶у鍙互鍙傝冧竴浜涙牸寮忥細
#!/bin/sh
#chkconfig: 2345 99 99
#description:the script to set the network at run level 2345
IN=eth0
OUT=eth1
HOST_NAME=cluster1.yang.com
INIP=192.168.10.10
OUTIP=192.168.136.10
MASK=255.255.255.0
IP=/sbin/ip
IFC=/sbin/ifconfig
ROUTE=/sbin/route
#flush the address
case "$1" in
start)
#echo "flush the address..."
#$IP addr flush dev eth0
#$IP addr flush dev eth1
echo "set the address..."
$IFC $IN $INIP netmask $MASK up
$IFC $OUT $OUTIP netmask $MASK up
echo "set the hostname..."
hostname $HOST_NAME
echo "set the default gateway..."
$IP route flush all
$ROUTE add default gw 192.168.136.2
echo "finshed!!!"
;;
stop)
echo "flush the network setting..."
$IP addr flush dev eth0
$IP addr flush dev eth1
echo "flush finshed!!!"
;;
status)
echo "hostname is $HOST_NAME"
$IFC eth0
$IFC eth1
;;
*)
echo "requires start,stop or status"
;;
esac
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
鍦↙inux涓璫hkconfighttpd浠誨姟娣誨姞錛孉pache鏈嶅姟鍣ㄧ殑鏈鏂扮ǔ瀹氬彂甯冪増鏈槸httpd-2.2..0,瀹樻柟涓嬭澆鍦板潃鏄細http://httpd.apache.org/download.cgi銆傛垜浠氳繃涓嬮潰鐨勬楠ゆ潵蹇熺殑鎼緩涓涓獁eb鏈嶅姟鍣ㄣ?/p>
1銆佷笅杞芥簮鐮佹枃浠秇ttpd-2.2.0.tar.gz 鍒發inux鏈嶅姟鍣ㄧ殑鏌愪釜鐩綍銆?br />2銆佽В鍘嬫枃浠?# tar zxvf httpd-2.2.0.tar.gz .
3銆侀厤緗?# ./configure –refix=/usr/local/apache //鎸囧畾瀹夎鐩綍錛屼互鍚庤鍒犻櫎瀹夎灝卞彧闇鍒犻櫎榪欎釜鐩綍銆?br />4銆佺紪璇戝拰瀹夎銆?# make ; make install .
5銆佺紪鍐欏惎鍔ㄨ剼鏈紝鎶婂畠鏀懼埌鐩綍 /etc/rc.d/init.d/閲岋紝榪欓噷鍙栧悕涓篽ttpd,鍏跺唴瀹瑰涓嬶細
- #!/bin/bash
- #description:http server
- #chkconfig: 235 98 98
- case "$1" in
- start)
- echo "Starting Apache daemon..."
- /usr/local/apache2/bin/apachectl -k start
- ;;
- stop)
- echo "Stopping Apache daemon..."
- /usr/local/apache2/bin/apachectl -k stop
- ;;
- restart)
- echo "Restarting Apache daemon..."
- /usr/local/apache2/bin/apachectl -k restart
- ;;
- status)
- statusproc /usr/local/apache2/bin/httpd
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|status}"
- exit 1
- ;;
- Esac
娉ㄦ剰錛?description:http server 榪欎竴琛屽繀欏誨姞涓?/strong>錛屽惁鍒欏湪鎵ц鍛戒護
# chkconfig –add httpd
鏃朵細鍑虹幇“service apache does not support chkconfig”鐨勯敊璇姤鍛娿?/p>
#chkconfig: 2345 98 98 琛ㄧず鍦ㄦ墽琛屽懡浠?/p>
# chkconfig –add httpd 鏃朵細鍦ㄧ洰褰?/etc/rc2.d/ 銆?etc/rc3.d/ /etc/rc5.d 鍒嗗埆鐢熸垚鏂囦歡 S98httpd鍜?K98httpd銆傝繖涓暟瀛楀彲浠ユ槸鍒殑銆?/p>
6銆佹墽琛屽懡浠?# chkconfig –add httpd 錛岃繘鍏ョ洰褰?etc/rc3.d/媯鏌ユ槸鍚︾敓鎴愭枃浠? S98httpd鍙奒98httpd.
7銆佸惎鍔ㄦ湇鍔?# service httpd start .

]]>