Cron not killing the running application when

April 20, 2011 at 05:40:54
Specs: solaries
Cron not killing the running application when there is nay update happend at oracle DB.

Hi , I have a perl script which i have called though shell by putting it into cron like below ,
* * * * * /export/home/aqr/QA/CommonRouting/aqr/resol/filter/filter_setEnv_test.sh

FIlter_setEnv_test.sh contain ,
#!/bin/bash
touch /tmp/started
export TNS_ADMIN=/export/home/aqr/QA/CommonRouting/aqr/resol/tnsnames;
export ORACLE_LIB=/tools/oracli-10.2/lib;
export LD_LIBRARY_PATH=.:/usr/lib:/usr/local/lib:$ORACLE_HOME/lib32;
export PERL5LIB=/tools/perl5/lib/site_perl;
export LD_LIBRARY_PATH_64=.:/opt/DSI/64;

echo "Environment Settings...Completed"
perl /export/home/aqr/QA/CommonRouting/aqr/resol/filter/filter_test.pl

-----------------
Filter_test.pl script is as follow ,
#!/usr/bin/perl -w
# Set environment variables
my $PERL_LIB = "/tools/perl5/lib/site_perl";
my $ORA_LIB = "/tools/oracli-10.2/lib";

$ENV{PERL5LIB}=$PERL_LIB;
$ENV{LD_LIBRARY_PATH}=$ORA_LIB;

print $::ENV{PERL5LIB};

# Set database credentials
my $dbase = "aqrq";
my $username = "aqr51_cr5";
my $passwd = "aqr51_cr5123";

# Set output file
my $TEMPFILE = "/tmp/temp.txt";

my $TEMPFILE1 = "/tmp/temp1.txt";
my $OUTFILE = "/export/home/aqr/QA/CommonRouting/aqr/resol/filter/filter.txt";
my $PID_FILE = "/export/home/aqr/QA/CommonRouting/aqr/resol/filter/pid_capture_file";

###########################################################################

my $fh1;
open($fh1, ">>$TEMPFILE1") or die "Unable to open output file\n";
print $fh1 "Sambit-Init 0";
use strict;
use DBI;

print $fh1 "env";
# Connect to databse
#my $dbh = DBI->connect( "dbi:Oracle:".$dbase, $username, $passwd )
# or die "Database connection not made: $DBI::errstr";


my $dbh = DBI->connect( "dbi:Oracle:$dbase", $username, $passwd );
print $fh1 "Sambit1 Test ";

# Fetch data from database
my $sql_select = "SELECT distinct OPC, DPC, CIC_START, CIC_END FROM VW_LOAD_SS7_EPS WHERE TRANSPARENCY like 'N'";
my $sth = $dbh->prepare($sql_select);
$sth->execute();

my $opc;
my $dpc;
my $cic_start;
my $cic_end;

$sth->bind_columns(\$opc, \$dpc, \$cic_start, \$cic_end);

print $fh1 "Sambit12 Test ";
# if output.txt exists, move output.txt to temp.txt
if(system("ls $OUTFILE > /dev/null 2>&1") == 0)
{
system("mv $OUTFILE $TEMPFILE");
}

# Prepare file for writing
my $fh;
open($fh, ">$OUTFILE") or die "Unable to open output file\n";

# Write into output file
while($sth->fetch())
{
print $fh "$opc,$dpc,$cic_start,$cic_end\n";
}


$dbh->disconnect;
# Compare with prev output
my @args = ("bash", "-c", "diff $OUTFILE $TEMPFILE > /dev/null 2>&1");
if(system("ls $TEMPFILE > /dev/null 2>&1") == 0)
{
if(system(@args) != 0)
{
print "SS7 EPS updated\n";

if(system("ls $PID_FILE > /dev/null 2>&1") == 0)
{


my $proc_pid;
open(proc_pid, "cat $PID_FILE |");
while (<proc_pid>)
{
chomp;
$proc_pid = $_;

}
print "Restarting Filter Process with pid $proc_pid\n";
system("/usr/local/bin/sudo kill -9 $proc_pid");

}
else
{
print "File $PID_FILE not found\n";
}
}
system("rm $TEMPFILE");
}

# Close file and database connection
close($fh);
close($fh1);

---------

Now i have one filter application which reads filter.txt created by filter.pl & Excutes. If there are any update done at DB , cron has to kill the filter application but it doesnt ? Also when i start the filter.pl script manually it kill the application.......... Please advise.

I have tried all the possiblities , like append it to the logs n all ............


See More: Cron not killing the running application when

Report •

#1
April 20, 2011 at 16:00:51
Set the PATH to the touch, echo and other such commands in your script. I'd do that first before anything else.

Report •
Related Solutions


Ask Question