[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: /etc/logrotate.d/httpd



Kai Hendry wrote:
Mike Kercher wrote:

Because the old log is rotated (mv'd to log.1/2/3) Restarting httpd allows
it to create a new log file...otherwise, nothing would get logged.


Shouldn't that be a PRErotate then?

I would think it needs to stop Apache. Then move log files. Then start again.

Else might there be danger of missing something?

I also find it disheartening that apache actually needs to restart for it to let go of the inode and start write logs again. Couldn't there be a softer way? Else the server might miss an incoming connection in the short time it's down?

Some of the [revious answers weren't quite right (and this might not be fully correct either), one of the hazards of free support and the Internet in general.

-HUP tells the kill command to send a hangup (think modem) signal (aka HUP) to Apache. HUP is commonly interpreted as a command to reread the configuration file, and Apache does this. Having reread the config file it acts on most of it, including the information about log files.


In *x, file names are created in a secondary index: the real index is a list of numbers (inodes). One can do pretty much anything with those index entries (they're called links) without necessarily having any effect on the file itself: renaming, deleting is fine.

A file is physically deleted when there is link for it _and_ it's closed. One can continue to read and write a file when it's been deleted: for this reason one sometimes needs to restart a process (or even reboot the system if the process is hung) to reclaim space.

In the case of the logrotate script, the mv commands rename the affected files, but Apache keeps writing to those that are in use.

The "kill -HUP" command causes Apache to reread the config files (not exactly restart), and having done so it reopens the log files using their old names. Those that have been renamed (mv) are then no longer in use. Nothing is lost, and there might be a brief pause while Apache sorts itself out, but nothing to worry about.







-

Cheers
John

-- spambait
1aaaaaaa computerdatasafe com au  Z1aaaaaaa computerdatasafe com au
Tourist pics http://portgeographe.environmentaldisasters.cds.merseine.nu/

do not reply off-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]