写Shell了

    技术2022-05-11  71

    #!/bin/bashset +xdt=`date '+%Y-%m-%d'`FILE=webkpi.log.${dt}

    ftp -in 130.38.18.166  <<!prompt offuser webcrm webcrm.11 cd /webapp/aioss/logs binlcd /opt/aiox/datapassive off get webkpi.log ./tmp1 bye!ftp -in 130.38.18.168 <<!prompt offuser webcrm webcrm.3cd /webapp/aioss/logsbinlcd /opt/aiox/datapassive offget webkpi.log ./tmp2bye!cd /opt/aiox/dataif [ -f tmp1 ]; thenif [ -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 tmp4fifi 

    FTP脚本,得到两个日志后合并sort, 保留当前时间段的日志.


    最新回复(0)