put this in cron:
*/10 * * * * root perl /pathToTheScript/httpdwatch.pl
And here's the script:
#!/usr/bin/perl
#================================================= =================httpdwatch.pl
# Objective: Periodically check in on httpd and start if necessary
# Inputs: None
# Outputs: None
# History:
# Programmer: Date: Modification:
# -------------- ---------- -------------------------------------------------
# Rob Burgess 10/02/2002 Original version
#================================================= ==============================
open(serviceStatus, "/sbin/service httpd status|");
$httpdStatus=<serviceStatus>;
chomp $httpdStatus;
close(serviceStatus);
if( $httpdStatus =~ /stopped/ ){
system("/sbin/service httpd start&");
}
elsif( $httpdStatus =~ /running/ ){#OK so far...
}
else{
print("Something is very wrong...(httpdwatch.pl)\n");
}#==============================EOF=============== ===============================
#edit: made some readability improvements
#edit: and a syntax error fix :|
Last edited by Arcturius; 10-02-2002 at 11:54 AM.
|