shell监控mysql端口是否运行,没有运行自动重启
时间:2020-04-11 18:32 来源:linux.it.net.cn 作者:IT
#!/bin/bash
/etc/init.d/mysqld status &> /dev/null
if [ $? -eq 0 ]
then
echo "mysql is running"
else
echo "警告:mysqld服务不可用"
echo "重启mysql服务:$(/etc/init.d/mysqld restart &> /dev/null)"
echo "mysql服务是否已经运行:$(ps -ef | grep mysqld)"
fi
(责任编辑:IT)
#!/bin/bash /etc/init.d/mysqld status &> /dev/null if [ $? -eq 0 ] then echo "mysql is running" else echo "警告:mysqld服务不可用" echo "重启mysql服务:$(/etc/init.d/mysqld restart &> /dev/null)" echo "mysql服务是否已经运行:$(ps -ef | grep mysqld)" fi (责任编辑:IT) |