How can I limit the size of Apache's access_log, and limit the number of archived logs it keeps?
On most Linux distributions, the system is set up to run logrotate on a daily basis. You won't see it in the crontab for root or for any particular user.
It's easy to change how it handles log files. On my Ubuntu server, the /etc/logrotate.conf
file has settings like these:
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
[etc.]
And, you can look in the directory /etc/logrotate.d/
to see settings for specific directories and apps.
I would use rotatelogs, a tool located in the apache bin directory.
See http://httpd.apache.org/docs/current/programs/rotatelogs.html for more information and examples. It has the advantage to exist on my HP-UX system.
Or as mentioned previously, you can use the logrotate tool that comes with most distributions.