sh Verificar estado de Apache和Mysql

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Verificar estado de Apache和Mysql相关的知识,希望对你有一定的参考价值。

#!/bin/bash
#---------------- Mysql --------------------------
if [[ ! "$(systemctl is-active mysql.service )" =~ "active" ]]
then
   echo $"Reiniciar MySql"
   sudo systemctl start mysql.service
else
  echo $"Mysql Funcionando"
fi

#---------------- APACHE --------------------------
echo $"--------- Apache -----------"
ps auxw | grep apache2 | grep -v grep > /dev/null
if [ $? != 0 ]
then
        echo $"Reiniciar Apache"
        sudo /etc/init.d/apache2 restart > /dev/null
    else
        echo $"Apache Funcionando"
fi

以上是关于sh Verificar estado de Apache和Mysql的主要内容,如果未能解决你的问题,请参考以下文章