What does nginx -s reopen do

nginx

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.

Best Answer

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).

Related Question