Verificar estado de Apache y 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