# use this script for the cron-job that checks for a running MathServe
# on the default server. It also restarts the server with the script given as
# first argument.
# the crontab should look like this:
# 30 0 * * * /usr/bin/perl /home.local/luettich/HDocs/HetCATS/utils/update_central_CASL-lib.pl /local/home/luettich/mathServ/restart.sh 'luettich@tzi.de' <more email addresses could follow>
use strict;
# if set to 0 no messages go to STDERR
# close STDERR
unless ($DEBUG) {
close STDERR;
close STDOUT;
}
if(@ARGV < 2) {
print STDERR "provide script and at least one email address!!\n";
exit 5;
}
my $restart_script = shift @ARGV;
## config
my $stderr_log_file = "/tmp/checkMathServe_errors.log";
# status variable
my $fail = 0;
# issue cvs cmd in the directory
my $ret_val = $? >> 8;
# check the exit value
if($ret_val) {
$fail++;
close SLOG;
}
if ($fail > 0) {
print STDERR "\n./CMDL_tests returned with exit code $ret_val -- sending Mail with this log-message:\n\n$log\n";
unless ($DEBUG) {
print MAIL "'CMDL_tests fast' failed with exit code $ret_val!\n\nSee following report for details:\n\n$log\n";
close MAIL;
}
}