Skip to content

Instantly share code, notes, and snippets.

@ahgood
Created May 3, 2018 05:55
Show Gist options
  • Save ahgood/de9fcc00f9ccf131f08d53548c6b911f to your computer and use it in GitHub Desktop.
Save ahgood/de9fcc00f9ccf131f08d53548c6b911f to your computer and use it in GitHub Desktop.
Monitor and restart MySQL
#!/bin/bash
if [[ ! "$(/usr/sbin/service mysql status)" =~ "active (running)" ]]
then
/etc/init.d/mysql stop
/etc/init.d/mysql start
echo "Restarted."
fi
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment