This is the code which are executing by using crontab schedulers without checking whether the file is empty or not,because fo this we are getting many alert mails when ever it is executing empty file i.e., zero byte file.So we need to write a condition like
If File is empty not execute the command
else execute the file with the command.
Note:Files are present in this path /amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/queue/SubmDist/subscribe.SubmAPCD
It should pick the latest file check for zero byte if not execute the command with the file which we checked above.
Code:
#!/bin/ksh
project3='/amex/abinitio/private_sand/GES/GlobalCapture/subm_I3'
subm=$project3
#echo $subm
export AB_HOME=/amex/abinitio/etl/abinitio-V2-14
export AB_AIR_ROOT=//148.173.245.169/amex/abinitio/reposit-V2-14/eme-V2-14
echo "Connected to EME 2-14"
export CLASSPATH=$CLASSPATH:/amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/Jars/mail-1.4.jar
export CLASSPATH=$CLASSPATH:/amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/Jars/activation-1.1.jar
export CLASSPATH=$CLASSPATH:/amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/Jars/
export CLASSPATH=$CLASSPATH:/amex/abinitio/private_sand/GES/GlobalCapture/subm_I3/class/
export PATH=$AB_HOME/bin:$PATH:/amex/abinitio/public_sand/stdenv/bin
export PATH=.:$AB_HOME/bin:/opt/IBMIHS/IBMJava2-142/bin:$PATH
envir=$subm
db2name="/usr/local/db2/db2clnt2/sqllib/db2profile"
. $envir/ab_project_setup.ksh $envir
## For accessing databse from unix linux servers
if [ -f /usr/local/db2/db2clnt1/sqllib/db2profile ]
then
. /usr/local/db2/db2clnt1/sqllib/db2profile
elif [ `uname -s` = "Linux" ]
then
if [ `uname -a | awk '{ print $2 }'` = "lpdma512" ]
then
. /db2/db2clnt1/sqllib/db2profile
elif [ `uname -a | awk '{ print $2 }'` = "lpdwa723" ]
then
. /usr/local/db2/db2clnt2/sqllib/db2profile
elif [ `uname -a | awk '{ print $2 }'` = "lpqma515" ]
then
. /usr/local/db2/db2clnt1/sqllib/db2profile
fi
fi
# ---- GLOBAL VARIABLE ---------#
export ProcessStartTS=`date '+%Y-%m-%d-%H.%M.%S'`
export LogName=$AI_SERIAL_LOG/APCDAutomation_${ProcessStartTS}.log
# export FileCount=`ls -lrt $AI_SERIAL_INBOX | tail -1 | egrep -v '\.SC|\.SP1|\.SP2' | wc -l`
#------------GRAPH FUNCTIONS ---------- #
function run
{
GraphName=$1
print "Processing $GraphName on $(date)" >> $LogName
$AI_BIN/./$GraphName >> $LogName
if [[ $? -ne 0 ]] then
print "$GraphName Failed " >> $LogName
EmailFailedMsg $GraphName
BackUpFailedGraph $GraphName
exit 3
fi
}
function EmailFailedMsg
{
Graph=$1
`java -classpath $CLASSPATH sendmailJobFail alert krb
@yahoo.com abc@yahoo.com $Graph`
}
function BackUpFailedGraph
{
GraphNm=$1
case $GraphNm in
"SubDisA.ksh" ) cp $AI_SERIAL/ListOfAPCDFiles.dat $AI_SERIAL/OPbackup/ListOfAPCDFiles-${ProcessStartTS}.dat;;
esac
}
function CleanUp
{
cp -f /dev/null $AI_SERIAL_LOOKUP/Sha1FileHistoryLookup.dat
}
# ------MAIN FUNCTION------------------ #
print " Running files for One Point Automation on $(date) " >> $LogName
# if [ $FileCount = 0 ]
# then
# echo "No file is not in inbox"
# exit 2
# fi
run SubDisA.ksh
# CleanUp # clear the sha1 and the input file
---------- Post updated at 10:01 AM ---------- Previous update was at 04:27 AM ----------
This is the code which are executing by using crontab schedulers without checking whether the file is empty or not,because fo this we are getting many alert mails when ever it is executing empty file i.e., zero byte file.So we need to write a condition like
If File is empty not execute the command
else execute the file with the command.
Note:Files are present in this path /amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/queue/SubmDist/subscribe.SubmAPCD
It should pick the latest file check for zero byte if not execute the command with the file which we checked above.
Code:
#!/bin/ksh
project3='/amex/abinitio/private_sand/GES/GlobalCapture/subm_I3'
subm=$project3
#echo $subm
export AB_HOME=/amex/abinitio/etl/abinitio-V2-14
export AB_AIR_ROOT=//148.173.245.169/amex/abinitio/reposit-V2-14/eme-V2-14
echo "Connected to EME 2-14"
export CLASSPATH=$CLASSPATH:/amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/Jars/mail-1.4.jar
export CLASSPATH=$CLASSPATH:/amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/Jars/activation-1.1.jar
export CLASSPATH=$CLASSPATH:/amex/abinitio/data_mount/GES/GlobalCapture/subm_I3/serial/Jars/
export CLASSPATH=$CLASSPATH:/amex/abinitio/private_sand/GES/GlobalCapture/subm_I3/class/
export PATH=$AB_HOME/bin:$PATH:/amex/abinitio/public_sand/stdenv/bin
export PATH=.:$AB_HOME/bin:/opt/IBMIHS/IBMJava2-142/bin:$PATH
envir=$subm
db2name="/usr/local/db2/db2clnt2/sqllib/db2profile"
. $envir/ab_project_setup.ksh $envir
## For accessing databse from unix linux servers
if [ -f /usr/local/db2/db2clnt1/sqllib/db2profile ]
then
. /usr/local/db2/db2clnt1/sqllib/db2profile
elif [ `uname -s` = "Linux" ]
then
if [ `uname -a | awk '{ print $2 }'` = "lpdma512" ]
then
. /db2/db2clnt1/sqllib/db2profile
elif [ `uname -a | awk '{ print $2 }'` = "lpdwa723" ]
then
. /usr/local/db2/db2clnt2/sqllib/db2profile
elif [ `uname -a | awk '{ print $2 }'` = "lpqma515" ]
then
. /usr/local/db2/db2clnt1/sqllib/db2profile
fi
fi
# ---- GLOBAL VARIABLE ---------#
export ProcessStartTS=`date '+%Y-%m-%d-%H.%M.%S'`
export LogName=$AI_SERIAL_LOG/APCDAutomation_${ProcessStartTS}.log
# export FileCount=`ls -lrt $AI_SERIAL_INBOX | tail -1 | egrep -v '\.SC|\.SP1|\.SP2' | wc -l`
#------------GRAPH FUNCTIONS ---------- #
function run
{
GraphName=$1
print "Processing $GraphName on $(date)" >> $LogName
$AI_BIN/./$GraphName >> $LogName
if [[ $? -ne 0 ]] then
print "$GraphName Failed " >> $LogName
EmailFailedMsg $GraphName
BackUpFailedGraph $GraphName
exit 3
fi
}
function EmailFailedMsg
{
Graph=$1
`java -classpath $CLASSPATH sendmailJobFail alert krb
@yahoo.com abc@yahoo.com $Graph`
}
function BackUpFailedGraph
{
GraphNm=$1
case $GraphNm in
"SubDisA.ksh" ) cp $AI_SERIAL/ListOfAPCDFiles.dat $AI_SERIAL/OPbackup/ListOfAPCDFiles-${ProcessStartTS}.dat;;
esac
}
function CleanUp
{
cp -f /dev/null $AI_SERIAL_LOOKUP/Sha1FileHistoryLookup.dat
}
# ------MAIN FUNCTION------------------ #
print " Running files for One Point Automation on $(date) " >> $LogName
# if [ $FileCount = 0 ]
# then
# echo "No file is not in inbox"
# exit 2
# fi
run SubDisA.ksh
# CleanUp # clear the sha1 and the input file