Stop crond When mysqld is Down
Tagged with: crond, Linux, mysql, Perl, script
Wednesday, December 5th, 2007 11:01 PM
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";