标签:action 脚本案例 res 成功 cat mon bin /etc/ gre
[root@m01 20171207]# cat ryn_srv.sh #!/bin/bash rsn_file="/usr/bin/rsync" # 判断启动的进程数 [ -e /etc/init.d/functions ] && source /etc/init.d/functions || echo "/etc/init.d/functions 不存在" [ -e ${rsn_file} ] || { echo "${rsn_file} 服务不存在" exit 11 } args1=$1 function start() { if [ $(ps -ef|grep "rsync --d[a]emon"|wc -l) -gt 0 ] then echo "rsync 已经启动" else ${rsn_file} --daemon sleep 1 [ $(ps -ef|grep "rsync --d[a]emon"|wc -l) -gt 0 ] && action "rsync 启动成功" /bin/true || echo "启动失败" fi } function stop() { if [ $(ps -ef|grep "rsync --d[a]emon"|wc -l) -gt 0 ] then killall rsync killall rsync &>/dev/null sleep 1 [ $(ps -ef|grep "rsync --d[a]emon"|wc -l) -lt 1 ] && action "rsync 关闭成功" /bin/true || echo "关闭失败" else echo "rsync 已经关闭" fi } function restart() { stop sleep 2 start } case $args1 in start) start ;; stop) stop ;; restart) restart ;; *) echo "Usage {start|stop|restart}" ;; esac
标签:action 脚本案例 res 成功 cat mon bin /etc/ gre
原文地址:http://www.cnblogs.com/gaoyuechen/p/7999680.html