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

Rsync服务启动脚本

时间:2015-12-16 09:42:04      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:rsync

#!/bin/sh
#filename:rsync_start.sh
#date:2015-12-14
#作者:linuxzkq
#version:v1.0

# chkconfig: 2345 23 65
# description: Start rsync and stop rsync scripts.

prog="rsync"
pidfile=/var/run/rsyncd.pid
exec=/usr/bin/rsync

. /etc/init.d/functions
[ -f /usr/bin/rsync ] || echo "please install and config rsync!"

#USAGE
function USAGE(){
  echo "USAGE:$0 {start|stop|restart}"
  exit 1
}

#start
function start(){
  $exec --daemon >/dev/null 2>&1
  if [ -s "$pidfile" ]
   then
    action "rsync haved already been running" /bin/false
  else
    $exec --daemon >/dev/null 2>&1
    action "start rsyncd:" /bin/true
  fi
}

#stop
function stop(){
  if [ -f "$pidfile" ]
   then     
    kill -USR2 `cat $pidfile`
    rm -f ${pidfile}
    action "stop rsyncd:" /bin/true
  else
    action "rsync no running!" /bin/false
  fi
}

case "$1" in
  start) start
         RETVAL=$?
         ;;
   stop) stop
         RETVAL=$?
         ;;
restart) stop && sleep 2 && start
         RETVAL=$?
         ;;
      *) echo "Error,Please use an USAGE!"
    USAGE
esac
exit $RETVAL


欢迎各位网友拍砖,老鸟及高手指正!

本文出自 “兰州linux运维” 博客,请务必保留此出处http://linuxzkq.blog.51cto.com/9379412/1723344

Rsync服务启动脚本

标签:rsync

原文地址:http://linuxzkq.blog.51cto.com/9379412/1723344

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