任务计划
crontab -l
1 15 * * * /home/dongnan/sh/split.sh >> /home/dongnan/sh/cron.log 2>&
nginx 日志
ls /var/log/nginx/
20130730-access.log.gz 20130801-access.log.gz 20130803-access.log.gz
20130730-error.log.gz 20130801-error.log.gz 20130803-error.log.gz
20130731-access.log.gz 20130802-access.log.gz access.log
20130731-error.log.gz 20130802-error.log.gz error.log
shell 脚本
cat split.sh
nginx日志切割脚本:
vi /root/cutlog.sh
mv $ACCLOG.`date -d "-10 day" +%F`.* /mnt/history.nginx.log/ #将10天前的老日志清理到其他地方,(你们如果想删除的可以自己改成删除)
mv $ERRLOG.`date -d "-10 day" +%F`.* /mnt/history.nginx.log/
fi
fi
nginx日志分析脚本:
vi /mnt/logs/checklog.sh
echo "#####FIND $M###############">>/mnt/logs/400.txt #分析错误请求
cat $1 | grep "/" $M " | grep -v ' "-" "-" - ' | sort | awk '{print $1 $2 $3 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16 $17 $18 $19 $20 $21}' | sort | uniq -c | sort -rn | head -n5 >> /mnt/logs/400.txt
fi
done
cat $1 | grep -v ' "-" "-" - ' | awk -F'T' '{print $2}' | awk -F'?' '{print $1}' | sort |awk '{print $1}' | sed 's//(//review//file//download///).*//1/g' | sort | uniq -c | sort -rn | head -n20 >> /mnt/logs/URL.txt
新闻热点
疑难解答