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.
Asked
Active
Viewed 5,927 times
1 Answers
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
logrotateregularly truncates these files, and creates archives of what's been truncated. This is why your/var/logdirectory usually fills up with.gzfiles. – John WH Smith Feb 25 '15 at 15:25