zoukankan      html  css  js  c++  java
  • 开发rsync启动脚本

    rsync

    rsync是类unix系统下的数据镜像备份工具——remote sync。一款快速增量备份工具 Remote Sync,远程同步 支持本地复制,或者与其他SSH、rsync主机同步。
     

    启动/停止命令:

    rsync --daemon
    pkillall rsync
     

    rsync脚本

    #!/bin/bash
    
    if [ $# -ne 1 ];then
            echo $"usage:$0 {start|stop|restart}"
            exit 1
    fi
    
    if [ "$1" = "start" ];then
            rsync --daemon
            sleep 1
            if [ `netstat -lntup|grep rsync|wc -l` -ge 1 ];then
                    echo "rsyncd is started."
                    exit 0
            fi
    elif [ "$1" = "stop" ];then
            killall rsync
            sleep 1
            if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ];then
                    echo "rsyncd is stopped."
                    exit 0
            fi
    elif [ "$1" == "restart" ];then
            killall rsync &>/dev/null
            sleep 1
            killpro=`netstat -lntup|grep rsync|wc -l`
            rsync --daemon
            sleep 1
            startpro=`netstat -lntup|grep rsync|wc -l`
            if [ $killpro -eq 0 -a $startpro -ge 1 ];then
                    echo "rsyncd is restarted."
                    exit 0
            fi
    else
            echo $"usage:$0 {start|stop|restart}"
            exit 1
    fi

    添加到chkconfig

    需要在脚本开头添加以下两行内容: 2345启动基本, 20启动顺序,80停止顺序

    #chkconfig: 2345 20  80
    #description: create by vincen
    #!/bin/bash
    #chkconfig: 2345 20  80
    #description: create by vincen
    if [ $# -ne 1 ];then
            echo $"usage:$0 {start|stop|restart}"
            exit 1
    fi
    
    if [ "$1" = "start" ];then
            rsync --daemon
            sleep 1
            if [ `netstat -lntup|grep rsync|wc -l` -ge 1 ];then
                    echo "rsyncd is started."
                    exit 0
            fi
    elif [ "$1" = "stop" ];then
            killall rsync
            sleep 1
            if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ];then
                    echo "rsyncd is stopped."
                    exit 0
            fi
    elif [ "$1" == "restart" ];then
            killall rsync &>/dev/null
            sleep 1
            killpro=`netstat -lntup|grep rsync|wc -l`
            rsync --daemon
            sleep 1
            startpro=`netstat -lntup|grep rsync|wc -l`
            if [ $killpro -eq 0 -a $startpro -ge 1 ];then
                    echo "rsyncd is restarted."
                    exit 0
            fi
    else
            echo $"usage:$0 {start|stop|restart}"
            exit 1
    fi
    [root@rhel6 ~]# chkconfig --list rsyncd
    service rsyncd supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add rsyncd')
    [root@rhel6 ~]# chkconfig --add rsyncd
    [root@rhel6 ~]# chkconfig --list rsyncd
    rsyncd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
  • 相关阅读:
    centos/7/isos/x86_64 下载
    Zend Guard Run-time support missing 问题的解决
    php.ini
    PS 基础知识 .pat文件如何使用
    PS 基础知识 .atn文件如何使用
    PS 如何用制作键盘图标
    PS 如何制作WIN7的玻璃化透明窗口效果
    PS常用平面设计制作尺寸
    如何使用Medieval CUE Splitter分割ape,合并ape,制作cue
    如何将MID音乐转换成MP3
  • 原文地址:https://www.cnblogs.com/vincenshen/p/6588862.html
Copyright © 2011-2022 走看看