#!/usr/bash
curDir=/app/cur
hisDir=/app/his
newDir=/app/new
newFile=xxxx_`date +%Y%m%d%H%M%S`_100.txt
#每天開始合並標志文件的時間點,各業務系統約定的時間點后開始,比如23點30分后
runTime=153000
echo"======腳本開始執行======="
while true
do
hh=`date '+%H%M%S'`
echo"======$hh=======$runTime========="
if [ $hh -gt $runTime ]
then
echo "開始處理 $curDir 目錄下的各子系統標志文件"
ls $curDir/*.txt |
while read file_name
do
echo "${file_name%.*} 合並到 $newFile"
cat $file_name >> $newDir/${newFile##*/}
echo "${file_name%.*} 移到 $hisDir "
mv $file_name $hisDir/${file_name##*/}
done
fi
#半個小時輪詢一次,也可以用crontab來設置定時任務
sleep 1800
done