shell分析nginx access log日志

统计访问最多的ip

1. tail -n 10000 xxaccess_log | cut -d " " -f 1 |sort|uniq -c|sort -rn|head -10 |more

2.tail -n 10000 xx-access_log | awk '{print $1}'|sort|uniq -c|sort -rn|head -10 | more

统计访问最多的url

tail -n 10000 xx-access_log |awk '{print $7}'| sort|uniq -c| sort -rn| head -10 | more

指定ip统计访问最多的url

tail -n 1000 xx-access_log | grep ‘00.00.00.00’|awk '{print $7}'| sort|uniq -c| sort -rn| head -10 | more

通过日志查看当天访问次数最多的时间段

tail -n 1000 xx-access_log | awk '{print $4}'|cut -c 14-21 |sort|uniq -c|sort -rn|head -10|more