Send email for Siebel tasks running longer than 2 hours in Linux 7

41 views Asked by At

I have a requirement of sending email to users if certain siebel tasks are running for more than 2 hours. The duration of 2 hours should be based on the difference between TK_START_TIME column value and system date.

Below is the sample output of the running tasks and the email sent to users should include only the rows that match the 2 hour threshold criteria.

SV_NAME  CC_ALIAS  TK_TASKID  TK_PID  TK_DISP_RUNSTATE  TK_START_TIME  TK_STATUS  TK_LABEL  TK_TASKTYPE
-------  --------  ---------  ------  ----------------  -------------  ---------  --------  -----------
crmappdev01  XMLPReportServer  28312493   22271   Running           2023-04-27 03:03:57  Waiting for command  intusr  Normal
crmappdev01  XMLPReportServer  28312478   22271   Running           2023-04-27 03:00:41  Waiting for command  intusr  Normal
crmappdev01  XMLPReportServer  28311601   22271   Running           2023-04-26 10:33:42  Waiting for command  intusr  Normal

I copied the output in a file and named it "2a_out_1.txt"

I am not an expert. But did search in google and tried the below code. But could go nowhere. Please help.

`while read -r line; do 
date_from_file=`awk '{ print $6, $7 }' 2a_out_1.txt`
start=$(date -d "$date_from_file" +%s)
end=$(date +%s)
elapsedTime=$((($end-$start)/(60*60)))
if [ $elapsedTime -gt 2 ]
    then
echo $line > 2a_final_out.txt
fi
done > 2a_out_1.txt`
0

There are 0 answers