nginx访问日志按天自动切割

sh脚本

#!/bin/bash
#Rotate the Nginx logs to prevent a single logfile from consuming too much disk space.
LOGS_PATH=/www/wwwlogs
YESTERDAY=$(date -d "yesterday" +%Y-%m-%d)
mv ${LOGS_PATH}/loveProject.access.log ${LOGS_PATH}/access_${YESTERDAY}.log
## 向 Nginx 主进程发送 USR1 信号。USR1 信号是重新打开日志文件
/usr/local/nginx/sbin/nginx -s reopen
#gzip ${LOGS_PATH}/access_${YESTERDAY}.log

定时任务

0 0 * * * sh /www/cron/loveProject/nginx_log_rotate.sh

你可能感兴趣的:(nginx,运维)