rsync启动关闭shell脚本
2017-10-16 22:08
453 查看
此脚本可放在/etc/init.d/目录里用service rsyncd start\stop\status\restart进行管理,还可以用chkconfig进行开机自启动管理,详细脚本内容如下:
#!/bin/bash # ****************************************************** # Author : wangning # Last modified: 2017-10-16 19:20 # Email : 1198143315@qq.com # Filename : rsyncd # Description : # ****************************************************** # chkconfig: 2345 78 79 # description: This is a rsyncd script . /etc/init.d/functions start() { rsync --daemon &>/dev/null if [ $? = 0 ];then action "startting rsync" /bin/true else action "startting rsync" /bin/false fi } stop() { if [ -e /var/run/rsyncd.pid ];then kill `cat /var/run/rsyncd.pid` &>/dev/null action "stopping rsync" /bin/true else echo "the rsyncd is not running" fi } status() { if [ -e "/var/run/rsyncd.pid" ];then echo -e "\033[32m rsyncd is running \033[0m" else echo -e "\033[31m rsyncd is stopped \033[0m" fi } restart() { kill `cat /var/run/rsyncd.pid` &>/dev/null action "stopping rsync" /bin/true sleep 3 rsync --daemon &>/dev/null action "startting rsync" /bin/true } case $1 in start) start ;; stop) stop ;; status) status ;; restart) restart ;; *) echo "USAG: $0 {start|stop|status|restart}" esac
相关文章推荐
- hadoop集群一键自动启动和自动关闭shell脚本 原创 2017年07月23日 17:58:45
- linux环境下编写shell脚本启动和关闭jar包服务程序
- shell脚本启动关闭tomcat,查看日志和备份项目
- 在linux中安装jdk以及tomcat并shell脚本关闭启动的进程
- 一个nginx启动关闭重启的shell脚本
- 企业Shell面试题15:开发Rsync服务启动脚本案例
- CentOS6.8 x86_64bit shell脚本实现模拟nginx服务启动与关闭
- shell 脚本解压war包+备份+tomcat自动关闭+启动
- shell脚本启动,关闭tomcat
- SHELL脚本实现Oracle自启动与关闭
- Linux之shell脚本系列 ----- 服务启动/关闭/重启/状态
- Shell开发rsync启动脚本
- 使用shell脚本 启动关闭tomcat服务
- 基于HBase和ZK 高可用集群环境 Shell脚本启动、关闭、重启、查看进程
- 利用shell开发rsync服务启动脚本
- 【springboot】之利用shell脚本优雅启动,关闭springboot服务
- 使用shell脚本 启动关闭tomcat服务
- 使用shell脚本启动关闭memcache服务
- 用shell编写nginx脚本的启动,关闭,重加载
- Shell脚本控制tomcat的docker容器的创建,删除,启动,关闭