httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Reppucci <...@logsoft.com>
Subject Re: Cleaning log files
Date Wed, 13 Mar 2002 11:54:52 GMT

Depends on how you define "safe", but I'd *not* use the method
you've illustrated here...

Apache still has the original log file open, so even after doing the
'cat', it'll still go along happily writing to the (now unlinked)
log file, and you'll lose those log records.  Depending upon whether
you're trying to preserve those logs (e.g., for traffic analysis)
this could be "a bad thing".  Regardless, the disk storage for the
logs won't be released until apache closes the log file.

I've used logrotate before, but for a few large sites I maintained,
I was happier with a couple of custom shell scripts I hacked
together that (after 'grep'ing through the server configs to find
the log files) did the equivalent of:

   mv access_log access_log.yyyyddmm.hhmmss
   apachectl graceful

The 'graceful' sends a SIGUSR1 to the apache parent process, which
causes it to tell all of its children to close and reopen the log
file *after* completing any current transaction.  This technique has
always worked like a charm for me.

Note that this is how it works under Unix, all bets are off as to
how the Win* OSes handle it...

hth,
<Steve>

On Wed, 13 Mar 2002, Dror Braznitzki wrote:

> Is it safe to clean log files using 'cat /dev/null > log_file' while the
> server is running ?
> Is there a better way of doing it ?
>
> Thanx,
> Dror
-- 
Steve Reppucci                                       sgr@logsoft.com |
Logical Choice Software                          http://logsoft.com/ |
=-=-=-=-=-=-=-=-=-=-  My God!  What have I done?  -=-=-=-=-=-=-=-=-=-=


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message