返回顶部

收藏

shell 日志统计程序

更多
  #!/bin/sh

  mday=$(date +%Y%m%d -d "1 day ago")
  fday=$(date +%m%d -d "1 day ago")  #filename
  filedir=/home/fanhy

  #echo $mday
  #cur_dir=$(pwd)
  #arg=$1
 #echo $arg
 #echo $mday
 #grep ' unsign' $filedir 
 #cat $filedir/*.txt|grep 'unsign' > $filedir/test.log
 grep ' unsign' $filedir/*_$fday.txt | awk -F "total): " '{print $2}'| awk '{a[$1]+=$2}END{for(i in a) if(i>0 && a[i]>0) print "INSERT INTO match_signret_stat(`ma
   tch_id`,`day`,`state`,`num`)VALUES(" i,"," m,"," 2,"," a[i] ");"}' RS=" " FS=":" m=$mday > $filedir/$mday.unsign.sql

 grep ' sign' $filedir/*_$fday.txt | awk -F "total): " '{print $2}'| awk '{a[$1]+=$2}END{for(i in a) if(i>0 && a[i]>0) print "INSERT INTO match_signret_stat(`matc
   h_id`,`day`,`state`,`num`)VALUES(" i,"," m,"," 1,"," a[i] ");"}' RS=" " FS=":" m=$mday > $filedir/$mday.sign.sql

 ##mysql insert
 /usr/bin/mysql -uroot jjstat < $filedir/$mday.unsign.sql;
 /usr/bin/mysql -uroot jjstat < $filedir/$mday.sign.sql;

标签:shell,日志统计,linux

收藏

0人收藏

支持

0

反对

0

发表评论