nginx访问日志和错误日志分割

#!/bin/sh
# Program:
#     Auto cut nginx log script.
# nginx日志路径
LOGS_PATH=/home/wwwlogs
TODAY=$(date -d 'today' +%Y-%m-%d)
# 移动日志并改名
mv ${LOGS_PATH}/hisense.error.log ${LOGS_PATH}/hisense/hisense_error_${TODAY}.log
mv ${LOGS_PATH}/hisense.access.log ${LOGS_PATH}/hisense/hisense_access_${TODAY}.log
# 向nginx主进程发送重新打开日志文件的信号
kill -USR1 $(cat /usr/local/nginx/logs/nginx.pid)

  chmod a+x cutnginxlog.sh

08 19 * * *  /usr/local/nginx/cutnginxlog.sh >> /var/log/cutnginxlog.log 2>&1

  

https://www.shuzhiduo.com/A/QW5Y7x3qzm/

posted @ 2023-02-06 19:12  Abner3721  阅读(30)  评论(0编辑  收藏  举报