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

rsync scripts

时间:2018-01-16 18:36:21      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:daemon   netstat   exit   rsync   null   grep   scripts   sage   code   

#! /bin/bash

if [ $# -ne 1 ];then
echo " usage:$0 {start|stop|restart}"
exit 5
fi

if [ "$1" = "start" ];then
rsync --daemon
sleep 1
if [ netstat -tnlup | grep rsync | wc -l -ge 1 ];then
echo "rsync server is running."
exit 0
fi
elif [ "$1" = "stop" ];then
killall rysnc &> /dev/null
sleep 1
if [ netstat -tnlup | grep rsync | wc -l -eq 0 ];then
echo "rsync is stopped."
exit 0
fi
elif [ "$1" = "restart" ];then
killall rsync &> /de/null
sleep 1
killpro=netstat -tlnup | grep rsync | wc -l
rsync --daemon
sleep 1
startpro=netstat -tnlup | grep rsync | wc -l
if [ $killpro -eq 0 -a $startpro -ge 1 ];then
echo "rsyncd is restart"
exit 0
fi

else
echo $"usage:$0 {start|stop|restart}"
exit 1
fi

rsync scripts

标签:daemon   netstat   exit   rsync   null   grep   scripts   sage   code   

原文地址:http://blog.51cto.com/546136/2061525

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