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

1
2
3
4
5
6
7
8
9
10
11
#!/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

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

  

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

posted @   Abner3721  阅读(39)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示