rsync 启动脚本

Posted sweet22353

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rsync 启动脚本相关的知识,希望对你有一定的参考价值。

#!/bin/bash
. /etc/init.d/functions
pidfile="/var/run/rsyncd.pid"
start_rsync="rsync --daemon --config=/etc/rsyncd.conf"
status1=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v ‘grep‘)

function usage() 
    echo $"usage:$0 start|stop|restart"
    exit 1


function start() 
    sleep 1
    if [ "$status1X" == "X" ];then
        rm -rf $pidfile
        $start_rsync
        status2=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v ‘grep‘)
        if [ "$status2X" != "X" ];then
            action "rsyncd is started." /bin/true
        else
            action "rsyncd is started." /bin/false
        fi
    fi
 

function stop 
    killall rsync &> /dev/null
    rm -rf $pidfile
    sleep 1
    if [ `netstat -anlpe |grep rysnc |wc -l ` -eq 0 ];then
        action "rsyncd is stoped." /bin/true
    else
        action "rsyncd is stoped." /bin/false
    fi


function status() 
    if [ "$status1X" == "X" ];then
        action "sync is not rununing"
    else
        action "syncd is running"
    fi




function main() 
    if [ $# -ne 1 ];then
        usage $0
    fi
    case $1 in
        start)
              start
              ;;
    stop)
              stop
              ;;
    restart)
              stop
              start
              ;;
    status)
             status
              ;;
    *)
      echo
          echo  "Usage: $0 start|stop|restart|status"
      echo
    ;;
esac


main $*

  

以上是关于rsync 启动脚本的主要内容,如果未能解决你的问题,请参考以下文章

开发rsync启动脚本2

rsync启动停止脚本

rsync 启动脚本

开发rsync服务的启动脚本

rsync启动关闭shell脚本

rsync启动脚本