码迷,mamicode.com
首页 > 其他好文 > 详细

rsync 启动脚本

时间:2019-07-26 14:52:35      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:als   cas   daemon   cti   div   res   killall   gre   ase   

#!/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 $*

  

rsync 启动脚本

标签:als   cas   daemon   cti   div   res   killall   gre   ase   

原文地址:https://www.cnblogs.com/sweet22353/p/11249935.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!