candy 发表于 2016-12-29 06:12:51

shell awk读取Nginx最近5分钟的访问日志数

  脚本代码

date1=`date -d "$date1" +%Y%H%M`
logpath="access.log"
cat $logpath |awk -v now=$date1 'BEGIN{count=0}{if(match($4,'/\\\\/+/')){ date=substr($4,RSTART+1,10);if(date>=now && match($10,"500")){count=count+1;}}} END{print count}'
页: [1]
查看完整版本: shell awk读取Nginx最近5分钟的访问日志数