if [ $# -ne 1 ];then #! /bin/bash #chkconfig 2345 30 60 #This scripts is sync

if [ $# -ne 1 ];then echo $"usage:$0 {start|stop|restart}" exit 1 fi if [ $1 = "start" ];then sync --dameon sleep 2 if [ netstat -tnlup | grep rsync | wc -l -ge 1 ];then echo "The sync services starting.." exit 0 fi elif [ $1 = "stop" ];then killall rsync &> /dev/null sleep 1 if [ netstat -tnlup | grep rsync | wc -l -eq 0 ];then echo "The sync services stopping.." exit 0 fi elif [ $1 = "restart" ];then killall rsync sleep 1 if [ netstat -tnlup | grep rsync | wc -l -eq 0 ];then k1=1 echo "The rsync services stopping.." fi sync --dameon sleep 2 if [ netstat -tnlup | grep rsync | wc -l -ge 1 ];then s1=1 echo "The sync services starting.." fi if [ $k1 -eq 1 -a $s1 -eq 1 ];then echo "The rsync service restart ..." exit 0 fi else echo "please input right arguments..." fi