开发rsync服务的启动脚本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了开发rsync服务的启动脚本相关的知识,希望对你有一定的参考价值。
开发rsync服务的启动脚本
1、查看rsync软件包是否安装:
[[email protected] scripts]# rpm -qa rsync rsync-3.0.6-9.el6_4.1.x86_64 [[email protected] scripts]# touch /etc/rsyncd.conf [[email protected] scripts]# rsync --daemon [[email protected] scripts]# netstat -lntup |grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 31908/rsync tcp 0 0 :::873 :::* LISTEN 31908/rsync [[email protected] scripts]# pkill rsync
2、开发rsync服务的启动脚本:
[[email protected] scripts]# vi rsyncd.sh [[email protected] scripts]# cat /etc/init.d/rsyncd #!/bin/bash # chkconfig:2345 20 80 #description:Rsyncd Startup scripts by fzhddn. if [ $# -ne 1 ] then echo $"usage:$0 {start|stop|restart}" exit 1 fi if [ "$1" = "start" ] then rsync --daemon sleep 2 if [ `netstat -lntup|grep rsync|wc -l` -ge 1 ] then echo "resyncd is started." exit 0 fi elif [ "$1" = "stop" ] then killall rsync &>/dev/null sleep 2 if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ] then echo "rsyncd is stopped." exit 0 fi elif [ "$1" = "restart" ] then killall rsync sleep 1 killpro=`netstat -lntup|grep rsync|wc -l` rsync --daemon sleep 1 startpro=`netstat -lntup|grep rsync|wc -l` if [ $killpro -eq 0 -a $startpro -ge 1 ] then echo "rsyncd is restarted." exit 0 fi else echo $"usage:$0 {start|stop|restart}" exit 1 fi
3、对启动脚本进行测试
[[email protected] scripts]# sh rsyncd.sh usage:rsyncd.sh {start|stop|restart} [[email protected] scripts]# sh rsyncd.sh start resyncd is started. [[email protected] scripts]# sh rsyncd.sh restart rsyncd is restarted. [[email protected] scripts]# sh rsyncd.sh stop rsyncd is stopped. [[email protected] scripts]# sh rsyncd.sh start resyncd is started. [[email protected] scripts]# netstat -tlnup |grep 873 tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 16073/rsync tcp 0 0 :::873 :::* LISTEN 16073/rsync
4、设置为rsync服务,开机自启动
[[email protected] scripts]# cp rsyncd.sh /etc/init.d/rsyncd [[email protected] scripts]# chmod +x /etc/init.d/rsyncd [[email protected] scripts]# chkconfig --list rsyncd service rsyncd supports chkconfig, but is not referenced in any runlevel (run ‘chkconfig --add rsyncd‘) [[email protected] scripts]# chkconfig --add rsyncd [[email protected] scripts]# chkconfig --list rsyncd rsyncd 0:off1:off2:on3:on4:on5:on6:off [[email protected] scripts]#
本文出自 “福州恒达电脑” 博客,请务必保留此出处http://fzhddn.blog.51cto.com/12650899/1944984
以上是关于开发rsync服务的启动脚本的主要内容,如果未能解决你的问题,请参考以下文章