1. 程式人生 > >rsync啟動腳本

rsync啟動腳本

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


本文出自 “10997527” 博客,謝絕轉載!

rsync啟動腳本