开发rsync服务的启动脚本
2017-07-06 13:52
344 查看
开发rsync服务的启动脚本
1、查看rsync软件包是否安装:
2、开发rsync服务的启动脚本:
1、查看rsync软件包是否安装:
[root@sxun scripts]# rpm -qa rsync rsync-3.0.6-9.el6_4.1.x86_64 [root@sxun scripts]# touch /etc/rsyncd.conf [root@sxun scripts]# rsync --daemon [root@sxun 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 [root@sxun scripts]# pkill rsync
2、开发rsync服务的启动脚本:
[root@sxun scripts]# vi rsyncd.sh [root@sxun 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 fi3、对启动脚本进行测试
[root@sxun scripts]# sh rsyncd.sh usage:rsyncd.sh {start|stop|restart} [root@sxun scripts]# sh rsyncd.sh start resyncd is started. [root@sxun scripts]# sh rsyncd.sh restart rsyncd is restarted. [root@sxun scripts]# sh rsyncd.sh stop rsyncd is stopped. [root@sxun scripts]# sh rsyncd.sh start resyncd is started. [root@sxun 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/rsync4、设置为rsync服务,开机自启动
[root@sxun scripts]# cp rsyncd.sh /etc/init.d/rsyncd [root@sxun scripts]# chmod +x /etc/init.d/rsyncd [root@sxun scripts]# chkconfig --list rsyncd service rsyncd supports chkconfig, but is not referenced in any runlevel (run 'chkconfig --add rsyncd') [root@sxun scripts]# chkconfig --add rsyncd [root@sxun scripts]# chkconfig --list rsyncd rsyncd 0:off1:off2:on3:on4:on5:on6:off [root@sxun scripts]#
相关文章推荐
- 利用shell开发rsync服务启动脚本
- 开发启动rsync服务的脚本
- 企业Shell面试题15:开发Rsync服务启动脚本案例
- Rsync服务启动脚本
- 启动rsync服务的脚本并能用chkconfig管理
- rsync服务启动脚本,通过chkconfig来管理开机自启动
- linux系统服务rsync启动脚本
- Shell开发rsync启动脚本
- 通过Shell开发企业级专业服务启动脚本案例(MySQL)
- linux系统服务rsync启动脚本
- Windows Service开发日志四(用程序设置服务的运行状态及启动方式)
- 【脚本工具】启动各种数据库服务的脚本,快捷便利
- [原创]Oracle服务、ORCL实例手动启动脚本
- 启动Oracle,SQL服务,IIS脚本
- U8服务手动启动脚本
- CentOS Tomcat 的启动服务脚本
- C# Windows 服务开发并启动
- 利用脚本禁止与启动Microsoft SQL Server相关服务
- Google android初级开发之 : android 模拟器启动脚本(for windows)
- windows下mysql启动停止服务示例脚本