zoukankan      html  css  js  c++  java
  • 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 [ "${status1}X" == "X" ];then
            rm -rf $pidfile
            ${start_rsync}
            status2=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v 'grep')
            if [ "${status2}X" != "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 [ "${status1}X" == "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 $*
    

      

  • 相关阅读:
    最好的云备份选项
    不要让你的云备份策略退居次位
    了解区域类型
    Managing WMI security
    创建、导入、导出、复制以及粘贴 WMI 筛选器
    Gpfixup
    centos 7 安装MySQL 5.7.23
    centos 7 配置 mysql 5.7 主从复制
    oracle DG搭建
    undo表空间丢失、损坏
  • 原文地址:https://www.cnblogs.com/sweet22353/p/11249935.html
Copyright © 2011-2022 走看看