logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.
/etc/logrotate.conf
It includes items from the directory include /etc/logrotate.d
which is where your individual logconfig files will be stored.
$ vi /etc/logrotate.d/rennetti
/var/www/vhosts/rennetti.com/logs/*.log /var/www/vhosts/staging.rennetti.com/logs/*.log
{
notifempty
missingok
rotate 14 # only keep 14 days
daily # rotate daily (or weekly, monthly, yearly)
size 50M # rotate at 50M (or 100k, 100G)
compress # Gzip cmpression
delaycompress # Don't copress until the next log is rotated
sharedscripts # don't run postrotate until every log file is rotated
postrotate
/usr/sbin/apachectl graceful > /dev/null
endscript
}
Verify it works: logrotate -d
-d = debug and runs through the scripts but doesn't actually do anything
logrotate -f -v /etc/logrotate.d/rennetti
-f = force and -v verbose/var/lib/logrotate.status
http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats
Logrotate is not a daemon so it need sto run on cron: You will likely find it
/etc/cron.daily/logrotate