linux配置nginx定时日志分割

【linux配置nginx定时日志分割】脚本内容:
cat /app/cut_ngx_log.sh#!/bin/sh# Program:#Auto cut nginx log script.# nginx日志路径 LOGS_PATH=/app/nginx/logsTODAY=$(date -d 'today' +%Y-%m-%d)# 移动日志并改名mv ${LOGS_PATH}/error.log ${LOGS_PATH}/error_${TODAY}.logmv ${LOGS_PATH}/access.log ${LOGS_PATH}/access_${TODAY}.log# 向nginx主进程发送重新打开日志文件的信号kill -USR1 $(cat /app/nginx/logs/nginx.pid)#自动删除30天前的指定日志文件find ${LOGS_PATH}/ -mtime +30 -name "error*.log" -exec rm -rf {} \;find ${LOGS_PATH}/ -mtime +30 -name "access*.log" -exec rm -rf {} \;授权并添加定时任务
chmod +x /app/cut_ngx_log.shecho '59 23 * * * sh /app/cut_ngx_log.sh >> /app/nginx/logs/cutnginxlog.log 2>&1' >> /etc/crontab