nginx docker 方式启动后日志切分的正确姿势


Linux系统的日志文件的切分主要是由logrotate来完成的,以centos7为例配置通常在/etc/logrotate.d 目录下

 

添加 nginx 文件

 

cat nginx

 

/var/log/nginx/*.log {
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root root
        sharedscripts
        postrotate
           # [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`    
            docker inspect -f '{{ .State.Pid }}' nginx | xargs kill -USR1
        endscript
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM