Created
March 11, 2014 18:15
-
-
Save allanlaal/9491720 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* @desc MySQL restarter | |
* @example # /root/scripts/mysql_restarter.php >> /root/scripts/mysql_restarter.log | |
* @author Allan Laal <[email protected]> | |
* @since 2013-10-05 | |
* @version DIRTY | |
*/ | |
// monitortest can be an unprivileged user: | |
$connection_result = mysql_connect('localhost', 'monitortest', 'INSERT_PASSWORD_HERE'); | |
if ($connection_result === FALSE) | |
{ | |
echo date('Y-m-d H:i:s')." MySQL is DOWN, attempting restart\n"; | |
exec( | |
'PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'.";\n". | |
'/usr/sbin/service mysql restart >> /root/scripts/mysql_restarter.log'.";\n" | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment