[plug] Batch Task

Brian Tombleson brian at ParadigmIT.com.au
Fri Jan 26 20:14:02 WST 2001


How about reconfigure syslogd to pipe logs from that program to a program
that will check and then re-start the appropriate app?

Note: completely untested perl script!

In /etc/syslog.conf:

# My app is on local6, so redirect to the new script.
local6.*        | /usr/local/sbin/logcheck

Then write the script and put execute permissions on
/usr/local/sbin/logcheck :

#!/usr/bin/perl -w
# File in /usr/local/sbin/logcheck
use strict;
$logfile = "/var/log/youir_log";
open(LOGFILE, ">>$logfile") || die "Cannot open $logfile: $!\n";
while <STDIN> {
  if (index('rc = -136',$_) == -1) {
    system '/etc/rc.d/init.d/yourapp restart';
  }
  print LOGFILE $_;
}

This is just an idea you may want to look further into :)

- Brian.

----- Original Message -----
From: "Robert Andrews" <squirrel at emerge.net.au>
To: "Perth Linux Group" <plug at plug.linux.org.au>
Sent: Friday, January 26, 2001 6:48 PM
Subject: [plug] Batch Task


Hi all on a redhat 6.1 system how can I set up a task that every few mins
checks for a line in a log file that reads "(rc = -136)" then restart a
application
I have very little experiance with scripts.
Thanks







More information about the plug mailing list