核心代码:
复制代码 代码如下:
#/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
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
内蒙古资源网 Copyright www.nmgbbs.com
暂无“一个shell for循环与case结合的脚本(监控程序状态)”评论...