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?

user1065145
  • 295
  • 4
  • 9

1 Answers1

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

Anatoly
  • 556
  • 3
  • 16