系统相关
首页 > 系统相关> > nginx 日志分割压缩

nginx 日志分割压缩

作者:互联网

利用 logrotate 自动处理日志

本logrotate 为linux自带,

配置文件在 /etc/logrotate.conf 

包含里面的子配置

vim /etc/logrotate.d/nginx

需要改log的目录

/usr/nginx/logs/*log {

create 0664 nginx root
daily
compress
rotate 30     # 轮询30天
missingok
notifempty
dateext
sharedscripts
postrotate
        if [ -f /run/nginx.pid ]; then
                kill -USR1 `cat /run/nginx.pid`
        fi
endscript




}

本脚本的执行文件(此文件为linux自带,一般不需要修改)

/etc/cron.daily/logrotate 

标签:run,log,etc,压缩,nginx,logrotate,linux,日志
来源: https://www.cnblogs.com/sdgtxuyong/p/16425771.html