Just learnt of this, that Nginx can be controlled from command line, or more specifically by sending signals to the process, for example:
kill -USR1 `cat /path/to/nginx.pid`
causes Nginx to reopen log files, suitable for a log rotation job.
The reference can be found at the wiki http://wiki.nginx.org/NginxCommandLine
Just a quick list of other stuff that you can send signals to Nginx to do:
- TERM, INT => quick shutdown
- QUIT => graceful shutdown
- HUP => reloads configuration
- USR1 => reopens log files
- USR2 => upgrades the executable on the fly
- WINCH => gracefully shutdown worker processes
There’re some instructions on how to do various stuffs so do check it out.
Thanks to Jim Ohlstein and 张立冰 for pointing this out.