-
-
Save d4nnr/2ca72e4331febf4345a0 to your computer and use it in GitHub Desktop.
Iniciar-Reiniciar MySQL y enviar un correo. Pueden crear un cron job de un reinicio diario.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Iniciar-Reiniciar MySQL y enviar un correo. | |
SERVICIOS=(Mysqld) | |
#Funcion para iniciar/reiniciar servicios | |
function servicioInit (){ | |
if ! service $1 status &>/dev/null; then | |
echo -n -e "\tIniciando $1 ..." | |
service $1 start &>/dev/null | |
echo 'Ok ...' | |
else | |
echo -n -e "\t $1 esta ejecutandose, pero reiniciando servicio..." | |
service $1 restart &>/dev/null | |
echo 'Ok ...' | |
fi | |
} | |
for ((i=0; i<${#SERVICIOS[*]}; i++)) do #if $estado = "start"; then if [ -z $1 ]; then echo "Verificando servicio: ${SERVICIOS[$i]} ->" | |
servicioInit ${SERVICIOS[$i]} | |
done | |
echo "Enviando mail para soporte" | |
echo "Queremos informarle que el servicio de Mysql fue reiniciado Exitosamente..." | mail -s "Succefull MySQL restarted" soporte@Sudominio.com | |
echo "enviado" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment