Skip to content

Instantly share code, notes, and snippets.

@schellenbergk
Forked from mheadd/monitor.sh
Last active October 19, 2017 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schellenbergk/17d5763281923230cac2bd122877a597 to your computer and use it in GitHub Desktop.
Save schellenbergk/17d5763281923230cac2bd122877a597 to your computer and use it in GitHub Desktop.
Simple bash script to check whether MySQL is running.
#!/bin/bash
# crontab -e
# add:
# */5 * * * * /root/bin/cron_monitor_mysql > /dev/null 2>&1
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
else
echo "All is well.";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment