#!/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学习中的笔记
一直很喜欢写unix shell script, 因为写那么一点点东西可以有那么多效果,投入小,产出大,爽啊. 在写IBM AIX K Shell script时,感觉不那么友好,主要是有一些格式细节要求比较严格,不太习惯,后来写惯了也就好了,下面的...
shfmt_v3.1.2_windows_amd64.exe shfmt_v3.1.2_windows_386.exe 解决idea would you like to install a shell script formatter?的问题
身為 UNIX 系統管理者除了要熟悉 UNIX 指令外,我們最好學會幾種 scripts 語言,例如 shell script 或 perl。學會 script 語言後,我們就可以將日常的系統管理工作寫成一支執行檔,如此一來,在管理系統時就可以更加...
shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法shell script 交互语法
Linux shell Script
this is a shell script learning
shell script 语言教程 非常好的入门级材料,适合速成。
shellscript shellscript
Shell脚本编程(scripting)的技巧永远不会过时:它们可以让UNIX充分发挥其真实的潜能。对UNIX的用户与系统管理者而言,编写Shell脚本是必须的工作,它可以让你快速地控制与定制任何UNIX系统的强大功能。有了Shell...
C Shell 教程 英文版 2007年5月出版
shell_script.tar.gz
Jenkins构建Execute shell script on remote host using ssh命令;JenkinsSSH执行命令;
微软操作系统 windows脚本编程,适合初学者。
shell script 的语法、判断式、循环、括号的区别、跟踪与调试。
shell脚本参考和python脚本参考
shell-script-template, 简单( 希望有用) shell script 模板 通用模板 。描述数百万开发人员编写 shell 脚本来解决各种类型的任务。 我使用 shell 脚本简化部署。生命周期管理。安装或者仅仅作为一种粘合剂语言。 ...