Last active
April 26, 2016 09:14
-
-
Save MattHealy/d0e4168132f93759271f918270744b80 to your computer and use it in GitHub Desktop.
Check if MySQL/MariaDB is down, and if so, restart it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PORT=3306 | |
HP=:$PORT | |
echo 'Checking to see if MariaDB is up...' | |
if ( /usr/sbin/lsof -Pni $HP | grep "$PORT (LISTEN)" 2>&1 >/dev/null ); then | |
echo 'MariaDB is up'; | |
else | |
echo 'MariaDB is down, restarting...'; | |
/sbin/service mariadb restart | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment