2

In it's simplest realization, one can implement NGINX log rotation as following:

mv access.log access.log.0
kill -USR1 `cat master.nginx.pid`

My question. Do we have a concurrency issue here? I mean, if NGINX writes a log entry between two actions (1) file was renamed and (2) it got a command to reload, could some of log entries be just lost?

  • if it helps to you, please mark the answer as complete – Anatoly Jul 13 '15 at 17:28
  • 1
    @mikhailov Sure. Tnx for helping out! – user1065145 Jul 14 '15 at 6:34
3

Before send USR1 signal wait for 15 seconds and you will see that *access.log.0" is still being used. It happens because log is open for write access based on inode, not the file name. So it is concurrent-safe to use this technique: mv + USR1

| improve this answer | |

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.