一、编写定时切割nginx日志脚本
脚本名称:/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,每天凌晨切割nginx访问日志
00 00 * * * /bin/bash /usr/local/nginx/sbin/cut_nginx_log.sh
二、
阅读(821) | 评论(0) | 转发(0) |