I
don't know if this is the best way to go about this, but you can
configure Cron to run on a regular basis to run a small script that
will delete the old files in the /var/log/apache2 directory. Here are
the steps to do that.
1. Create a file named
ApacheLogRotateDelete in the /etc/cron.monthly directory.
2.
Paste the following into that ApacheLogRotateDelete
file:
#!/bin/bash
find /var/log/apache2/* -mtime +5 -exec rm {}
\;
3. Change the rights on
/etc/cron.monthly/ApacheLogRotateDelete
chmod 755
/etc/cron.monthly/ApacheLogRotateDelete
4. Restart cron
cd
/etc/init.d
./cron restart
NOTES:
Which files to delete:
The "find /var/log/apache2/*
-mtime +5 -exec rm {} \;" line causes all files greater than 5
days old to be deleted. You can change the number of days by changing
+5 to +10 days, or +x for some other number of days.
How
often to run the delete script:
The instructions above cause the
ApacheLogRotateDelete script to run every Month. You can have that
run daily or weekly by using the cron.daily or cron.weekly directory.