手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >一个shell for循环与case结合的脚本(监控程序状态)
一个shell for循环与case结合的脚本(监控程序状态)
摘要:核心代码:复制代码代码如下:#/bin/bashset-xHOSTS="nginxmysqlphp-cgi"formyhostin$HOST...

核心代码:

复制代码 代码如下:

#/bin/bash

set -x

HOSTS="nginx mysql php-cgi"

for myhost in $HOSTS

do

count=(`ps aux |grep $myhost |grep -v grep |wc -l`)

echo "$myhost"

echo "$count"

if [ $count -eq 0 ]; then

case $myhost in

nginx)

cd /usr/local/webserver/nginx/sbin/

./nginx

echo "nginx has be down"

sleep 5

mysql)

/etc/init.d/mysqld start

echo "mysql has be down"

*)

echo "what‘s the hell?"

esac

fi

done

set +x

【一个shell for循环与case结合的脚本(监控程序状态)】相关文章:

shell脚本实现实时检测文件变更

linux shell实现判断输入的数字是否为合理的浮点数

shell for循环与数组应用介绍

Shell脚本实现监控MySQL主从同步

收集的48个Shell脚本小技巧

如何编写健壮的Bash脚本(经验分享)

shell结合expect写的批量scp脚本工具

Shell脚本实现监控iptables运行状态

Linux中执行shell脚本的4种方法总结

分享一个入门级可控多线程shell脚本代码

精品推荐
分类导航