#!/bin/bash
set +x
dt=`date '+%Y-%m-%d'`
FILE=webkpi.log.${dt}
ftp -in 130.38.18.166 <<!
prompt off
user webcrm webcrm.11
cd /webapp/aioss/logs
bin
lcd /opt/aiox/data
passive off
get webkpi.log ./tmp1
bye
!
ftp -in 130.38.18.168 <<!
prompt off
user webcrm webcrm.3
cd /webapp/aioss/logs
bin
lcd /opt/aiox/data
passive off
get webkpi.log ./tmp2
bye
!
cd /opt/aiox/data
if [ -f tmp1 ]; then
if [ -f tmp2 ]; then
sort -n tmp1 tmp2 > tmp3
date=`date '+%Y%m%d'`
hour=`date '+%H'`
min=`date '+%M'`
second='00'
if [ $hour -ne 0 ]; then
case $min in
15)
min='00'
;;
30|45)
min=`expr $min - 15`
;;
*)
hour=`expr $hour - 1`
min=45
;;
esac
else
case $min in
15)
min='00'
;;
30|45)
min=`expr $min -15`
;;
esac
fi
if [ $hour -lt 10 ]; then
hour='0'$hour
fi
awkparam="/$1 >= $date$hour$min$second"
awk -F, "$awkparam" tmp3>tmp4
mv tmp4 $FILE
rm -f tmp1 tmp2 tmp3 tmp4
fi
fi
FTP脚本,得到两个日志后合并sort, 保留当前时间段的日志.