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]