RSYNC服务启动脚本

1.rsync服务启动脚本

#!/bin/bash
. /etc/init.d/functions
function usage(){
echo $"USAGE:$0 {START|STOP|RESTART}"
exit 1
}
function start(){
rsync --daemon
sleep 2
if [ `netstat -lntup|grep rsync|wc -l` -ge 1 ]
then
action "rsync is started" /bin/true
exit 0
fi
}
function stop(){
killall rsync &>/dev/null
sleep 2
if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ]
then
action "rsync is stopped" /bin/true
exit 0
fi
}
function main(){
if [ $# -ne 1 ]
then
usage
fi
if [ "$1" = "start" ]
then
start
elif [ "$1" = "stop" ]
then
stop
elif [ "$1" = "restart" ]
then
stop
sleep 2
start
else
usage
fi
}
main $*


「 文章如果对你有帮助,请点个赞哦^^ 」 

0