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

rsync启动停止脚本

时间:2018-05-06 12:23:51      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:rsync   rsync启动停止脚本   

#!/bin/bash #this script for start|stop rsync daemon service #date:2018/5/6 status1=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v ‘grep‘) pidfile="/etc/rsync/rsyncd.pid" start_rsync="rsync --daemon --config=/etc/rsync/rsyncd.conf" function rsyncstart() { if [ "${status1}X" == "X" ];then rm -f $pidfile ${start_rsync} status2=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v ‘grep‘) if [ "${status2}X" != "X" ];then echo "rsync service start.......OK" fi else echo "rsync service is running !" fi } function rsyncstop() { if [ "${status1}X" != "X" ];then kill -9 $(cat $pidfile) status2=$(ps -ef | egrep "rsync --daemon.*rsyncd.conf" | grep -v ‘grep‘) if [ "${statusw2}X" == "X" ];then echo "rsync service stop.......OK" fi else echo "rsync service is not running !" fi } function rsyncstatus() { if [ "${status1}X" != "X" ];then echo "rsync service is running !" else echo "rsync service is not running !" fi } function rsyncrestart() { if [ "${status1}X" == "X" ];then echo "rsync service is not running..." rsyncstart else rsyncstop rsyncstart fi } case $1 in "start") rsyncstart ;; "stop") rsyncstop ;; "status") rsyncstatus ;; "restart") rsyncrestart ;; *) echo echo "Usage: $0 start|stop|restart|status" echo esac

rsync启动停止脚本

标签:rsync   rsync启动停止脚本   

原文地址:http://blog.51cto.com/6207422/2113215

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