[thelist] limit log file size in apache

Daniel J. Cody djc at five2one.org
Fri Oct 6 12:13:07 CDT 2000


Eric - 

There are a couple ways you can do this. Depending on what OS you're
using(and what flavor) there may be a pre-configured logrotate program
for you to use. If you're on a Linux system, check out
/etc/logrotate.conf and /etc/logrotate.d/httpd  - these should give you
an idea of how the logrotate program works, and it may suit your needs.

Otherwise, grab a perl module from CPAN called Logfile::Rotate and run
the following snippet with cron however often you want them to rotate.

use Logfile::Rotate;
$logfile = new Logfile::Rotate(
   File => '/usr/local/apache/logs/access_log',
   Count => 5,
   Gzip => '/bin/gzip',
   Signal => sub {
    `/usr/local/apache/bin/apachectl restart`;
                 }
    );

That will leave you with files called access_log.tar.1.gz for example,
and it will keep 5 of them onhand.(you can set that in the above script)

the perl mod handles all the details, and you can read more about it if
you're  looking for a more customized solution  :)

.djc.


Erik Sabowski wrote:
> 
> is there a directive for httpd.conf that will limit the size of your log
> files in apache? i could have sworn there was, but i have looked around for
> a while now and can't find it. so am i jsut not finding it, or is this just
> something i'll have to do manually through a perl/shell/whatever script?
> 
> thanks
> 
> #airyk




More information about the thelist mailing list