rsync啓動腳本

#!/bin/sh

#chkconfig: 2345 20  80

#description: create by bai

. /etc/init.d/functions

judge=`netstat -lntup|grep rsync|wc -l`

_start(){

if [ $judge -eq 2 ]

  then 

   action "rsync is running" /bin/true

else

  rsync --daemon

  sleep 1

  action "rsync  started" /bin/true

 fi

}

_stop(){

if [ `netstat -lntup|grep rsync|wc -l`  -ge 0 ]

   then

   killall rsync >/dev/null 2>&1

   sleep 3

  if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ]

     then

  action "rsync is stopped" /bin/true

  fi

else

  action "rsync is stopped" /bin/true

fi

}

case "$1" in 

start)

    _start

;;

stop)

    _stop

;;

restart)

  _stop 

  sleep 2

  _start

;;

*)

  echo $"usage:$0 {start|stop|restart}"

;;

esac


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章