nginx按天切割access.log日志存放

老牛  2015-08-23 17:22  阅读 966 views 次 评论 1 条
vi /usr/local/nginx/sbin/cut_nginx_log.sh
#!/bin/bash
# This script run at 00:00

# The Nginx logs path
logs_path="/usr/local/nginx/logs/"

mkdir -p ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/
mv ${logs_path}access.log ${logs_path}$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")/access_$(date -d "yesterday" +"%Y%m%d").log
kill -USR1 `cat /usr/local/nginx/nginx.pid`
crontab -e
00 00 * * * /bin/bash  /usr/local/nginx/sbin/cut_nginx_log.sh

来自张晏的脚本
http://blog.zyan.cc/nginx_php_v6/

历史上的今天:

本文地址:http://xiaohost.com/1331.html
版权声明:本文为原创文章,版权归 老牛 所有,欢迎分享本文,转载请保留出处!

发表评论


表情