本脚本估计存在一些问题:如有发现,请告知谢谢~

#!/bin/sh
# chkconfig: 2345 21 60
# description: Saves and restores system entropy pool for \
#create by xiaohu
#2014.06.02
#This script is the Rsync service script
. /etc/init.d/functions
case "$1" in
  start)
        echo "rsync is starting"
        rsync --daemon
        sleep 2
        myport=`netstat -lnt|grep 873|wc -l`
        if [ $myport -eq 2 ]
        then
        action "rsync start"   /bin/true
        else
        action "rsync start"   /bin/false
        fi
        ;;
  stop)
        echo "rsync is stoping"
        myport=`netstat -lnt|grep 873|wc -l`
        if [ $myport -eq 2 ]
        then 
        killall rsync &>/dev/null
        sleep 2
        killall rsync &>/dev/null
        sleep 1
        fi
        myport=`netstat -lnt|grep 873|wc -l`
        if [ $myport -ne 2 ]
        then
        action "rsync stop"   /bin/true
        else
        action "rsync stop"   /bin/false
        fi
        ;;
  restart)
        if [ `netstat -lnt|grep 873|wc -l` -eq 0 ]
        then
        rsync --daemon
        sleep 2
        myport=`netstat -lnt|grep 873|wc -l`
        if [ $myport -eq 2 ]
        then
        action "rsync restart"   /bin/true
        else
        action "rsync restart"   /bin/false
        exit
        fi
        else
        killall rsync &>/dev/null
        sleep 2
        killall rsync &>/dev/null
        sleep 1
        rsync --daemon
        sleep 2
        myport=`netstat -lnt|grep 873|wc -l`
        if [ $myport -eq 2 ]
        then
        action "rsync restart"   /bin/true
        else
        action "rsync restart"   /bin/false
        fi
        fi
        ;;
  status)
        myport=`netstat -lnt|grep 873|wc -l`
        if [ $myport -eq 2 ]
        then
        echo  "rsync is running"
        else
        echo "rsync is stoped"
        fi
        ;;
  *)
        echo $"Usage: $0 {start|stop|status|restart}"
        ;;
esac

    在stop参数中,不建议采用pkill或看kill,尤其是数据库方面,容易让服务出现问题。