Quantcast
Channel: Doyensys Allappsdba Blog..
Viewing all articles
Browse latest Browse all 1640

Script to terminate Forms Runaway Processes(Automaticall kill frmweb process that doesnot have proper db sessions)

$
0
0
#Script to Kill runaway Form processes

. Source your environment file here ######################

proc_file=file_directory_location/prc_id.log; export proc_file
op_log=file_directory_location/sess_proc_id.log; export op_log
op_log2=file_directory_location/sess_proc_id_2.log; export op_log2
op_log3=file_directory_location/grep_proc_id.sh; export op_log3
op_log4=file_directory_location/kill_proc_id.sh; export op_log4
dateis=`date +"%d"/"%m"/"%Y"_"%H":"%M":"%S"`; export dateis

proc_id_list=`ps -ef|grep -i frmweb|grep -v grep|awk '{print $2}'> $proc_file`; export proc_id_list

loop_list=`cat $proc_file`;export loop_list

for i in $loop_list
do
sqlplus -s 'system/**********'<< EOF >> $op_log
set serveroutput on;
set feedback off;
declare
prcs_id varchar2(30) :='$i';
lv_n_process varchar2(30);
begin
select distinct process into lv_n_process from
v\$session
where process =prcs_id;
exception
when no_data_found then
dbms_output.put_line('No Database Sessions For Process: '||prcs_id);
end;
/
exit;
EOF
done

op_count=`cat $op_log|wc -l`;export op_count
proc_grep=`cat $op_log|awk '{print "ps -ef|grep -i " $6}'> $op_log3`;export proc_grep
#echo $op_count
if [ $op_count = 0 ]
then
echo "########################################################################## \n">> $op_log2
echo "No Runaway Form Processes during last run at $dateis \n">> $op_log2
echo "########################################################################## \n">> $op_log2
else
echo "########################################################################## \n">> $op_log2
echo "\tFind the Runaway Form Processes during last run at $dateis as follows,">> $op_log2
cat $op_log >> $op_log2
echo "\n">> $op_log2
echo "\t\tGrepping the Form Processes(These Runaway Processes are going to be killed!!!!)">> $op_log2
sh "$op_log3"|grep -v grep >> $op_log2
echo "\n">> $op_log2
sh "$op_log3"|grep -v grep|awk '{print "kill -9 "$2}'> $op_log4
echo "\tRunaway Processes Killed">> $op_log2
cat $op_log4 >> $op_log2
sh "$op_log4">> $op_log2
echo "\n">> $op_log2
echo "########################################################################## \n">> $op_log2
fi
>$op_log

Viewing all articles
Browse latest Browse all 1640

Trending Articles