Skip to content

Instantly share code, notes, and snippets.

@puentesdiaz
Created October 4, 2013 13:44
Show Gist options
  • Save puentesdiaz/6826144 to your computer and use it in GitHub Desktop.
Save puentesdiaz/6826144 to your computer and use it in GitHub Desktop.
Verify if a Mysql Service are running, if not then restart it
#!/bin/sh
#chmod a+x /usr/local/bin/verificarServers.sh
#crontab -e
#0,15,30,45 * * * * /usr/local/bin/verificarServers.sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin
SERVICE='mysqld'
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
service mysql status > /dev/null
# mkdir /var/log/statusMysqlOK/$(($(date +%s%N)/1000000))
else
service mysql restart > /dev/null
# mkdir /var/log/statusMysqlDOWN/$(($(date +%s%N)/1000000))
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment