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

Re: Logrotate



On Mon, Jun 06, 2005 at 04:46:53PM +0200, Philippe de Rochambeau wrote:
> I am having trouble understanding the following /etc/logrotate.d/ file
> 
> httpd:
> 
> /var/log/httpd/*log {
>     missingok
>     notifempty
>     sharedscripts
>     postrotate
>         /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> 
> /dev/null || true
>     endscript
> }
> ~
> 
> The " /bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null 
> || true " line apparently means "kill the httpd daemon". But why would 
> you want to kill the httpd daemon after rotating the logs? 

kill -HUP means that you don't want to actually kill the daemon but to
send it a signal to wake up and re-read its configuration files and
re-open its log files.  In this case, it will open new copies of
access_log, error_log, etc.

> Furthermore, how would you write the above configuration file to rotate 
> log files whose names contain the current date (e.g., 20050606.log, 
> 20050607.log, etc.)?

In the postrotate section, rename the log file from whatever.log.1 to
the date format.  Remember, though, that you have to handle multiple
files.  You don't want to rename both access_log.1 and error_log.1 to
20050606.log.

If you do rename the log files, note that you'll be responsible for
cleaning them up.  logrotate normally will delete older files, keeping
by default 4 versions.  So, when it comes time to rotate log.4, it will
be deleted instead of being renamed to log.5.

-- 
Ed Wilts, RHCE
Mounds View, MN, USA
mailto:ewilts ewilts org
Member #1, Red Hat Community Ambassador Program



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