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

1
vi /usr/local/nginx/sbin/cut_nginx_log.sh
1
2
3
4
5
6
7
8
9
#!/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`
1
crontab -e
1
00 00 * * * /bin/bash  /usr/local/nginx/sbin/cut_nginx_log.sh

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

原文链接:https://xiaohost.com/10701.html,转载请注明出处。
0

评论1

请先