# Why Send HUP signal after rotating log files



## vivek (Mar 28, 2009)

I've lighttpd and Apache installed and every Sunday night log files get archived and rotated. However, I'm not sure why we need to send HUP single after archiving log files:

```
/lighttpd/var/log/example.com/error_log      644  5     *   D0 Z0 /var/run/lighttpd.pid HUP
```


----------



## fronclynne (Mar 28, 2009)

cos the now moved/gone/archived log file will still be open and being written to (and will keep filling your partition until you close all references to said file, like say, by HUPing lighttpd) and the new log file will remain nicely empty


----------



## DutchDaemon (Mar 28, 2009)

Mind you, this is only necessary for logfiles not created and written by syslogd. So if you have an application that can log using syslogd (e.g. BIND has an option for that, and applications like e.g. Sendmail and Dovecot do it by default), there's no need to HUP that application. Newsyslog will signal syslogd when rotating logfiles.

But if you're using newsyslog to rotate a logfile that's being written outside of syslogd (in other words: by the application itself), the writing application needs to be signalled in order to close the active file descriptor and open a new one to a new logfile. Or else the active file descriptor will simply move with the logfile being rotated and continue writing to it.


----------



## vivek (Mar 29, 2009)

Thanks for info. I've always blindly sent a HUP, but this Apache document recommends sending a SIGUSR1, not a HUP:
http://httpd.apache.org/docs/2.2/stopping.html

Quoting from above url:


> The USR1 or graceful signal causes the parent process to advise the children to exit after their current request (or to exit immediately if they're not serving anything). The parent re-reads its configuration files and re-opens its log files. As each child dies off the parent replaces it with a child from the new generation of the configuration, which begins serving new requests immediately.


----------

