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

rsync chkconfig scripts

时间:2018-03-13 11:03:24      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:linux bash

if [ $# -ne 1 ];then
#! /bin/bash
#chkconfig 2345 30 60
#This scripts is sync

if [ $# -ne 1 ];then
echo $"usage:$0 {start|stop|restart}"
exit 1
fi
if [ $1 = "start" ];then
sync --dameon
sleep 2
if [ netstat -tnlup | grep rsync | wc -l -ge 1 ];then
echo "The sync services starting.."
exit 0
fi
elif [ $1 = "stop" ];then
killall rsync &> /dev/null
sleep 1
if [ netstat -tnlup | grep rsync | wc -l -eq 0 ];then
echo "The sync services stopping.."
exit 0
fi
elif [ $1 = "restart" ];then
killall rsync
sleep 1
if [ netstat -tnlup | grep rsync | wc -l -eq 0 ];then
k1=1
echo "The rsync services stopping.."
fi
sync --dameon
sleep 2
if [ netstat -tnlup | grep rsync | wc -l -ge 1 ];then
s1=1
echo "The sync services starting.."
fi
if [ $k1 -eq 1 -a $s1 -eq 1 ];then
echo "The rsync service restart ..."
exit 0
fi
else
echo "please input right arguments..."
fi

rsync chkconfig scripts

标签:linux bash

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

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