rsync 启动脚本
#!/bin/bash
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool
. /etc/init.d/functions
function usage () {
echo $"usage:$0 {start|stop|restart}"
exit 1
}
function start () {
rsync --daemon
sleep 2
if [ `netstat -tnlp|grep rsync|wc -l` -ge 1 ]
then
action "rsyncd is started." /bin/true
else
action "rsyncd is stopped." /bin/false
fi
}
function stop () {
killall rsync &>/dev/null
sleep 2
if [ `netstat -tnlp|grep rsync|wc -l` -eq 0 ]
then
action "rsyncd is stopped." /bin/true
else
action "rsyncd is started" /bin/false
fi
}
function main () {
if [ $# -ne 1 ]
then
usage
fi
if [ "$1" = "start" ]
then
start
elif [ "$1" = "stop" ]
then
stop
elif [ "$1" = "restart" ]
then
stop
sleep 1
start
else
usage
fi
}
main $*
本文详细介绍了一个用于启动、停止和重启rsync服务的bash脚本。该脚本通过检查rsync进程状态来确保服务正确运行,使用netstat命令验证rsync守护进程是否正在监听,并通过sleep指令保证操作之间的稳定过渡。
470

被折叠的 条评论
为什么被折叠?



