You can use logrotate to do this (are you using it for other log files)? You can create an entry for squid in /etc/logrotate.d/squid and add the following content. This example rotates weekly for 5 weeks. The postrotate entry of
/usr/local/squid/sbin/squid -k rotate causes squid to close and re-open its logs so no silliness happens with open file handles For this to happen, your squid.conf file needs to have logfile_rotate set to 0:
Code:
/var/log/squid/access.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/var/log/squid/cache.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
}
/var/log/squid/store.log {
weekly
rotate 5
copytruncate
compress
notifempty
missingok
# This script asks squid to rotate its logs on its own.
# Restarting squid is a long process and it is not worth
# doing it just to rotate logs
postrotate
/usr/local/squid/sbin/squid -k rotate
endscript
}