Controlling Nginx from command line

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s