亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

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注冊服務(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)文章

最新評論