Skip to content

Instantly share code, notes, and snippets.

@KhanMaytok
Created April 25, 2015 00:26
Show Gist options
  • Save KhanMaytok/ccb590e92492591b41e6 to your computer and use it in GitHub Desktop.
Save KhanMaytok/ccb590e92492591b41e6 to your computer and use it in GitHub Desktop.
Restart mysql server if it is down
#!/bin/bash
UP=$(service mysql status|grep 'mysql start/running' | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start;
echo "MySQL has return";
else
echo "All is well.";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment