rsync启动停止脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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启动脚本编写

Shell开发rsync启动脚本

开发rsync启动脚本2

rsync 启动脚本

开发rsync服务的启动脚本

rsync启动脚本