Skip to content

Instantly share code, notes, and snippets.

@d4nnr
Last active August 29, 2015 13:56
Show Gist options
  • Save d4nnr/2ca72e4331febf4345a0 to your computer and use it in GitHub Desktop.
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.
#!/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