#!/bin/sh HOME=/opt/sonicMQ/transit SCRIPTS=$HOME/bin HLD_DIR=$HOME/holding LOGDIR=$HOME/log LOGFILE=transit.log LOGOUTPUT=$LOGDIR/$LOGFILE LOGSCRIPT=$SCRIPTS/Logger LOGLEVEL=DEBUG DIFF_TIME_TO_CHECK=1 DIFF_TIME_TO_DELETE=10 FILES="*.[DdXx][AaMm][TtLl]" EMAIL=xxxxx #EMAIL=xxxx DESCRIPTION="discription" CONTENT="" SUBJECT="File Not Processed Over Pre-determined time" JAVA_BIN=/app/bea/jdk131/jre/bin cd $HLD_DIR touch ../bin/FileStatusTEMP.log while read delFile do fileName=`echo $delFile | awk '{print $2}'` emailTime=`echo $delFile | awk '{print $1}'` delCurTime=`$JAVA_BIN/java -classpath %classpath%:/opt/sonicMQ/transit/bin/:.: com.xx.xxx.GetDate` delDiffTime=`expr $delCurTime - $emailTime` if [ $delDiffTime -ge $DIFF_TIME_TO_DELETE ]; then echo "delete File: "$fileName rm -f $fileName else echo "restore undelete File to a temp file: "$delFile echo $delFile >> ../bin/FileStatusTEMP.log fi done < ../bin/FileStatus.log echo "overwrite the FileStatus.log" cat ../bin/FileStatusTEMP.log > ../bin/FileStatus.log echo "remove the temp file" rm -f ../bin/FileStatusTEMP.log FLAG=1 echo "add the previous content to the email content" while read eachLine do CONTENT=${CONTENT}"\n$eachLine" done < ../bin/FileStatus.log for nonDatFile in `ll .| grep -v '^d' | awk '{print $9}' | grep -v '^$' | grep '\.[Dd][Aa][Tt]$' 2>/dev/null` do if grep $nonDatFile ../bin/FileStatus.log >/dev/null 2>&1 then echo "continue: "$nonDatFile continue fi CurTime=`$JAVA_BIN/java -classpath %classpath%:/opt/sonicMQ/transit/bin/:.: com.xx.xxx.GetDate` FileTime=`$JAVA_BIN/java -classpath %classpath%:/opt/sonicMQ/transit/bin/: com.xx.xxx.GetDate $HLD_DIR/$nonDatFile` DiffTime=`expr $CurTime - $FileTime` mainline=`head -1 $nonDatFile` isUNICODE=`sed -n "/FH/p" $nonDatFile | cut -c1,2 | tail -1` if [ $isUNICODE != "FH" ]; then echo "here" mainline=`sed -n "/FH/p" $nonDatFile | cut -c3- | tail -1` fi countryCode=`echo "$mainline" | cut -c65,66` echo "countryCode:"$countryCode version=`echo "$mainline" | cut -c3-8` echo "version:"$version if [ $version -eq 000110 ]; then COMPANYEMAIL=`echo "$mainline" | cut -c209-269` elif [ $version -eq 000121 ]; then COMPANYEMAIL=`echo "$mainline" | cut -c209-269` else COMPANYEMAIL=`echo "$mainline" | cut -c219-279` fi echo "COMPANYEMAIL:"$COMPANYEMAIL if [ $DiffTime -ge $DIFF_TIME_TO_CHECK ]; then echo "com1" mydate=`date` CONTENT=${CONTENT}"\n$nonDatFile\t""$countryCode\t""$mydate" echo $CurTime" "$nonDatFile >> ../bin/FileStatus.log FLAG=0; fi done if [ $FLAG -eq '0' ]; then echo "send email..." content="To: "$EMAIL"\nBcc: "$COMPANYEMAIL"\nSubject: "$SUBJECT"\n\n"$CONTENT" \n"$DESCRIPTION; echo $content | sendmail -t fi
shell script I
最新推荐文章于 2019-02-26 17:50:10 发布