Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my /etc/logrotate.d/nginx I saw,

/var/log/nginx/*.log {
        rotate 52
        create 640 nginx adm
                [ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`

The postrotate script looks like killing the nginx process, which does not make sense so I must be wrong.

What it is doing?

share|improve this question
up vote 3 down vote accepted

Nginx responds to the USR1 signal by reopening its log files.

The USR1 signal kills a program by default, but it's meant to be handled to do whatever the program finds useful. Each program defines what it does with USR1 and USR2; for Nginx, that's reopening the log files (for log rotation) and executing a new instance (for upgrades).

By convention, most daemons respond to the HUP signal by reloading their configuration file. Nginx follows this convention. The original intent of the HUP signal was to signal the end of a session to interactive process (modem hang up — the user's gone, there's no point in continuing), but that meaning doesn't apply to daemons.

share|improve this answer

The kill command generically sends POSIX signals to a process. The normal invocation sends SIGTERM, which asks a process to terminate. However, in your case the signal being sent is SIGUSR1 which in your case, asks nginx to recycle its log files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.