Apacheアクセスログ集計

Apache ログを awk と uniq だけで集計する - Qiita

grep 'May/2016' /var/log/httpd/access_log | awk '{print $4}' | cut -b 2-12 | sort | uniq -c          # 日別
grep '01/May/2016' /var/log/httpd/access_log | awk '{print $4}' | cut -b 2-15 | sort | uniq -c       # 時間別
grep '01/May/2016:01' /var/log/httpd/access_log | awk '{print $4}' | cut -b 2-18 | sort | uniq -c    # 分別
grep '01/May/2016:01:00' /var/log/httpd/access_log | awk '{print $4}' | cut -b 2-21 | sort | uniq -c # 秒別
[sone.ryota@esxi-ryo136 ~]$ grep '23/Nov/2020:14' /opt/redmine/apache2/logs/access_log |awk '{print $4}' |cut -b 2-18 |sort |uniq -c
     11 23/Nov/2020:14:31
      1 23/Nov/2020:14:32
[sone.ryota@esxi-ryo136 ~]$
echo "`date +'%Y-%m-%d_%H'` $*"
[sone.ryota@esxi-ryo136 ~]$ grep '23/Nov/2020:14' /opt/redmine/apache2/logs/access_log |awk '{print $4}' |cut -b 14-18 |sort |uniq -c
     11 14:31
      1 14:32
[sone.ryota@esxi-ryo136 ~]$