使用函数更加规范的开发rsync启动脚本

#!/bin/bash
#chkconfig:
#description: create by vincen . /etc/init.d/functions function usage(){
echo $"usage:$0 {start|stop|restart}"
exit
} function start(){
rsync --daemon
sleep
if [ `netstat -lntup|grep rsync|wc -l` -ge ];then
action "rsyncd is started." /bin/true
else
action "rsyncd is started." /bin/false
fi
} function stop(){
killall rsync
sleep
if [ `netstat -lntup|grep rsync|wc -l` -eq ];then
action "rsyncd is stopped." /bin/true
else
action "rsync is started." /bin/false
fi
} function main(){
if [ $# -ne ];then
usage
fi
if [ "$1" == "start" ];then
start
elif [ "$1" == "stop" ];then
stop
elif [ "$1" == "restart" ];then
stop
sleep
start
else
usage
fi
}
main $*

执行结果:

[root@rhel6 script]# /etc/init.d/rsyncd start
rsyncd is started. [ OK ]
[root@rhel6 script]# vim /etc/init.d/rsyncd
[root@rhel6 script]# /etc/init.d/rsyncd start
rsyncd is started. [ OK ]
[root@rhel6 script]# /etc/init.d/rsyncd stop
rsyncd is stopped. [ OK ]
[root@rhel6 script]# /etc/init.d/rsyncd restart
rsync: no process killed
rsyncd is stopped. [ OK ]
rsyncd is started. [ OK ]

开发rsync启动脚本2的更多相关文章

  1. 开发rsync启动脚本

    rsync rsync是类unix系统下的数据镜像备份工具——remote sync.一款快速增量备份工具 Remote Sync,远程同步 支持本地复制,或者与其他SSH.rsync主机同步.   ...

  2. rsync启动脚本

    rsync启动脚本 01 #!/bin/bash  www.ahlinux.com 02 # 03 # rsyncd      This shell script takes care of star ...

  3. 开发nginx启动脚本及开机自启管理(case)

    往往我们在工作中需要自行写一些脚本来管理服务,一旦服务异常或宕机等问题,脚本无法自行管理,当然我们可以写定时任务或将需要管理的脚本加入自启等方法来避免这种尴尬的事情,case适用与写启动脚本,下面给大 ...

  4. 15:开发Rsync服务启动脚本案例

    [root@m01 ~]# rsn_count="ps -ef|grep 'rsync --d[a]emon'|wc -l" [root@m01 ~]# echo ${rsn_co ...

  5. rsync随机启动脚本

    服务端 #!/bin/sh # chkconfig: # description: Saves and restores system entropy pool for \ #create by xi ...

  6. Unity3D开发入门教程(三)——添加启动脚本

    五邑隐侠,本名关健昌,12年游戏生涯. 本教程以 Unity 3D + VS Code + C# + tolua 为例. 一.启动脚本 第一篇 "搭建开发环境",在 "配 ...

  7. 【Linux开发】Linux启动脚本设置

    前言linux有自己一套完整的启动 体系,抓住了linux启动 的脉络,linux的启动 过程将不再神秘.阅读之前建议先看一下附图.本文中假设inittab中设置的init tree为:/etc/rc ...

  8. linux shell 之尝试编写 企业级 启动脚本

    企业Shell面试题10:开发企业级MySQL启动脚本 说明: MySQL启动命令为: 1 /bin/sh mysqld_safe --pid-file=$mysqld_pid_file_path 2 ...

  9. 老李推荐:第5章3节《MonkeyRunner源码剖析》Monkey原理分析-启动运行: 启动脚本

    老李推荐:第5章3节<MonkeyRunner源码剖析>Monkey原理分析-启动运行: 启动脚本   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜任自动化测试,性 ...

随机推荐

  1. Mysql查询结果只有一条的情况下把值赋值给变量,再用if else 流程判断

    BEGIN set @n=(SELECT count(day) from log where day=CURDATE()); THEN call m_LogInsert(); ELSE call m_ ...

  2. 【优才原创】Android的拖放机制

    优才网 [优才原创]Android的拖放机制 2016-04-18 优才学院 优才网 一.拖放机制概述 ² 拖放操作是手指触摸屏幕上的某一对象.然后拖动该对象.最后在屏幕的某个位置释放该对象并运行某种 ...

  3. 怎样封装RESTful Web Service

    所谓Web Service是一个平台独立的,低耦合的.自包括的.可编程的Web应用程序.有了Web Service异构系统之间就能够通过XML或JSON来交换数据,这样就能够用于开发分布式的互操作的应 ...

  4. Java和C++ 比較

    总体差别 1. C/C++是直接执行在机器上(编译后为机器码),而java编译后产生*.class文件(字节码)是执行在java虚拟机上在(JVM),经过JVM解译(机器码)再放到真实机器上执行. J ...

  5. JSTL JSP页面推断某个cookie的值和读取值....

    <c:if test="${cookie['woshop'].value eq '1'}">                 <div>           ...

  6. 快速搭建一个成熟,强壮的App框架【转载】

    App框架搭建 招聘信息: iOS 研发工程师 iOS开发工程师 iOS开发实习工程师 新浪微博-Android开发工程师&iOS开发工程师 美术设计师(2D) UI设计师 cocos2dx手 ...

  7. centos6.9使用NTFS-3G挂载ntfs文件系统

    centos6.9使用NTFS-3G挂载ntfs文件系统 工作中,难免需要到linux 系统上拷贝文件,但linux 自己不支持ntfs,下面就是解决问题的办法. NTFS-3G是一个开源软件,支持在 ...

  8. InitialContext和lookup

    http://wxg6203.iteye.com/blog/680830 最近因为工作需要开始学习Ejb3,遇到了一个让我很郁闷的事情,做一下小小的总结——小心new InitialContext() ...

  9. Javascript获取各种浏览器可见窗口大小

    function getInfo() { var s = ""; s += " 网页可见区域宽:"+ document.body.clientWidth; s ...

  10. iOS 3DES加密

    本文转载至 http://www.cocoachina.com/bbs/read.php?tid=177167 -(NSString *)TripleDES:(NSString *)plainText ...