rsync的服务启动脚本

#!/bin/bash
#author:Mr.chen
# chkconfig:35 13 91
# description:This is Rsync service management shell script
# Source function library
. /etc/rc.d/init.d/functions
start(){
    rsync --daemon
    if [ $? -eq 0 -a `ps -ef|grep -v grep|grep rsync|wc -l` -gt 0 ];then
        action "Starting Rsync:" /bin/true
        sleep 1
    else
        action "Starting Rsync:" /bin/false
        sleep 1
    fi
}
stop(){
    pkill rsync;sleep 1;pkill rsync
    if [ `ps -ef|grep -v grep|grep "rsync --daemon"|wc -l` -lt 1 ];then
        action "Stopping Rsync: " /bin/true
        sleep 1
    else
        action "Stopping Rsync:" /bin/true
        sleep 1
    fi
}
case "$1" in
    start)
        start;
        ;;
    stop)
        stop;
        ;;
    restart|reload)
        stop;
        start;
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|reload}"
        ;;
esac

 

posted @ 2018-10-25 14:52  cash_su  阅读(1533)  评论(0编辑  收藏  举报