7

What does 'nginx -s reopen' really do? The nginx documentation says that it reopens logs. I tried it out from a terminal while nginx was running, but nothing happened.

Prachi
  • 203

1 Answers1

7

Something happened. You just didn't see it :) Calling nginx -s reopen, or sending a SIGUSR1 signal to an nginx process, while cause nginx to reopen its logs files.

This can become handy in case you (or a program like logrotate) alter a log file and want nginx to refresh its file descriptors. By doing this, nginx places its write cursor at the (new) end of the file, and prevents log corruptions (which would occur if nginx wrote an entry at a wrong/outdated file offset).

John WH Smith
  • 15,880
  • 1
    Thanks! Another question. What does it mean to rotate logs? Why do we need to do it? – Prachi Feb 25 '15 at 15:24
  • 1
    Log rotation prevents log files from getting too big :) logrotate regularly truncates these files, and creates archives of what's been truncated. This is why your /var/log directory usually fills up with .gz files. – John WH Smith Feb 25 '15 at 15:25
  • @JohnWHSmith so is there a slight chance of loosing some entries between rotating this way? – Babu James Apr 14 '18 at 08:39
  • @JohnWHSmith is threre any resource where we can read more about this? – alamin Apr 28 '18 at 12:10