Posted under » Ubuntu » Apache on 08 Jan 2023
Ever since Hardy Heron, Ubuntu implemented logrotate.d on Apache and Mysql. You may find the configuration for apache here.
/etc/logrotate.d/apache2
For ubuntu 22.04 it may look like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /var/log/apache2/*.log { daily missingok rotate 14 compress delaycompress notifempty create 640 root adm sharedscripts prerotate if [ -d /etc/logrotate.d/httpd-prerotate ]; then run-parts /etc/logrotate.d/httpd-prerotate fi endscript postrotate if pgrep -f ^/usr/sbin/apache2 > /dev/null; then invoke-rc.d apache2 reload 2>&1 | logger -t apache2.logrotate fi endscript } |
It could be daily or weekly or monthly. If it is weekly, then files are created very Sunday. So if you have 5 Sundays in a month, you will have 5 files.
After 2 weeks, it compresses the file into a .gz to save space. Therefore if its still one week's old (.log.1) it won't gz the file yet.
The weekly files are numbered according to age and this is what the term "logrotate" comes about. To delete the older log, you delete the largest number.
Not sure about the sharedscripts part though.