欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Shell腳本注冊(cè)到Linux系統(tǒng)服務(wù)實(shí)例

 更新時(shí)間:2015年05月11日 09:33:49   投稿:junjie  
這篇文章主要介紹了Shell腳本注冊(cè)到Linux系統(tǒng)服務(wù)實(shí)例,本文給出一個(gè)可以作為L(zhǎng)inux服務(wù)的腳本實(shí)例,及加入服務(wù)的方法等步驟,需要的朋友可以參考下

注冊(cè)一個(gè)系統(tǒng)服務(wù),開機(jī)自啟動(dòng).

1 腳本編寫

#vim test.sh

復(fù)制代碼 代碼如下:

#!/bin/bash 
 
#description: hello.sh 
#chkconfig: 2345 20 81 
 
EXEC_PATH=/usr/local/ 
EXEC=hello.sh 
DAEMON=/usr/local/hello.sh 
PID_FILE=/var/run/hello.sh.pid 
 
. /etc/rc.d/init.d/functions 
 
if [ ! -x $EXEC_PATH/$EXEC ] ; then 
       echo "ERROR: $DAEMON not found" 
       exit 1 
fi 
 
stop() 

       echo "Stoping $EXEC ..." 
       ps aux | grep "$DAEMON" | kill -9 `awk '{print $2}'` >/dev/null 2>&1 
       rm -f $PID_FILE 
       usleep 100 
       echo "Shutting down $EXEC: [  OK  ]"     

 
start() 

       echo "Starting $EXEC ..." 
       $DAEMON > /dev/null & 
       pidof $EXEC > $PID_FILE 
       usleep 100 
       echo "Starting $EXEC: [  OK  ]"         

 
restart() 

    stop 
    start 

 
case "$1" in 
    start) 
        start 
        ;; 
    stop) 
        stop 
        ;; 
    restart) 
        restart 
        ;; 
    status) 
        status -p $PID_FILE $DAEMON 
        ;; 
    *) 
        echo "Usage: service $EXEC {start|stop|restart|status}" 
        exit 1 
esac 
 
exit $? 

2注冊(cè)服務(wù)

復(fù)制代碼 代碼如下:

# chmod 700 test.sh
# cp test.sh /etc/init.d/
# chkconfig --add test.sh
# chkconfig --list

3.刪除服務(wù)
復(fù)制代碼 代碼如下:

# chkconfig  --del test.sh

相關(guān)文章

最新評(píng)論