I'm hoping to get some direction on how to set up truncating and gzip'ing on my domains' access logs. I notice that the core nginx access logs get split and compressed by default, yet my individual access logs continue to grow.

Is this something that can be set up and is handled by nginx or something else on my system that is managing it's core logs?



/var/log/nginx/access_log {
    rotate 7
    size 5k
    dateformat -%Y-%m-%d
        test -r /var/run/nginx.pid && kill -USR1 `cat /var/run/nginx.pid`
| improve this answer | |
  • 1
    Awesome. Logrotate was new to me. Makes perfect sense now. Thanks! – Dog Sep 13 '12 at 15:41
  • man logrotate for additional details. – Seth Apr 3 '17 at 18:31
  • 1
    I had to do the following to make it start with new config: sudo logrotate -v -f /etc/logrotate.d/nginx – talsibony Mar 22 '18 at 10:54
  • 2
    The command that actually rotates the logs is "kill -USR1 /var/run/nginx.pid". This does not kill the Nginx process, but instead sends it a signal causing it to reload its log files. This will cause new requests to be logged to the refreshed log file. Source – Edson Horacio Junior Aug 9 '18 at 14:30
  • Could somebody explain what these are and what this is doing? – Esqarrouth Apr 3 '19 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.