05 Dec

Stop crond When mysqld is Down

A perl script to stop crond if mysqld is down


#!/usr/bin/perl

# See if MySQL server is alive or not
$mysql_status = `/etc/init.d/mysqld status`;
print "MySQL Status: $mysql_status\n";
unless($mysql_status =~ /running/) {
	print "Stopping Cron... ";
	#If MySQL is not running, kill the crond
	$cron = `/etc/init.d/crond stop`;
	print $cron;
}

print "\n";