• 开发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
  • 相关阅读:
    一个简单的NodeJs静态页面的web服务器
    javascript的use strict(使用严格模式)
    javascript声明对象时 带var和不带var的区别
    javascript对象的属性,方法,prototype作用范围分析.
    linux下两台服务器文件实时同步方案设计和实现
    Memcache mutex设计模式
    php内存管理
    php-fpm 和 mysql 之间的关系
    innoDB 下主键的思考
    哈希表的实现
  • 原文地址:https://www.cnblogs.com/vincenshen/p/6588862.html
Copyright © 2020-2023  润新知