-
-
Save nisdis/172450727db3220bc1948dabd10a7aac to your computer and use it in GitHub Desktop.
Simple bash script to check whether MySQL is running.
This file contains hidden or 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/bash | |
##checks if mysql and apache is up and running, also can be used to start the service on Debian type systems | |
## Contact: nissim at companyoftwo dot in | |
APUP=$(pgrep apache2 | wc -l); | |
MYUP=$(service mysql status | wc -l); | |
if [ "$MYUP" -lt 2 ]; | |
then | |
echo "MySQL is down."; | |
/usr/sbin/service mysql start | |
else | |
echo "MySQL is running..."; | |
fi | |
if [ "$APUP" -eq 0 ]; | |
then | |
echo "Apache2 is down."; | |
/usr/sbin/service apache2 start | |
else | |
echo "Apache2 is running..."; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment