首页 » 脚本 » 正文

nginx(ip)统计分析脚本

#!/bin/bash
#desc 统计nginx访问日志
#结果保存文件路径
saveFile=’/home/app/10.23.2.235/iptj/’;
#获取时间
#date=`date -d -5day +”%Y-%m-%d”`;
date=`date +”%Y-%m-%d”`;
Catalog=`mkdir $saveFile$date`;
echo “Catalog”;
datetime=`date -d -13hour +”%Y-%m-%d-%H”`;
echo “$datetime”;
#Result=`cat /var/share/owlogs/front/nginxlogs/$date/access/access_$datetime.log|awk  ‘{print $1 } ‘|uniq -c >/home/app/10.23.2.235/iptj/$date/$datetime.txt`;
Result=`awk ‘{print $1}’ /var/share/owlogs/front/nginxlogs/$date/access/access_$datetime.log | sort | uniq -c | sort -n -k 1 -r >/home/app/10.23.2.235/iptj/$date/$datetime.txt`;
echo “$Result”;

 

发表评论