您现在的位置是:网站首页> 编程资料编程资料
一个shell for循环与case结合的脚本(监控程序状态)_linux shell_
2023-05-26
344人已围观
简介 一个shell for循环与case结合的脚本(监控程序状态)_linux shell_
核心代码:
复制代码 代码如下:
#/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中case的用法学习笔记_linux shell_
- linux bash shell中case语句的实例_linux shell_
- linux bash中too many arguments问题的解决方法_linux shell_
- Hadoop单机版和全分布式(集群)安装_linux shell_
- Linux shell脚本全面学习入门_linux shell_
- shell去掉文件中空行(空白行)的方法详解_linux shell_
- shell脚本编程之for语句、if语句使用介绍_linux shell_
- bash脚本输入密码不回显问题的解决方法_linux shell_
- 消耗CPU资源的shell脚本_linux shell_
- Bash的For循环(根据每次递增的数)_linux shell_
