I am trying to enable log rotation for WordPress log files. I need to enable log rotation and after 30 days it needs to be compressed and archived after 60 it needs to be deleted.
I created a file app.conf in /etc/logrotate.d folder with the below content:
/var/www/firebolt-app/wp-content/*.log {
weekly
rotate 4
maxage 90
}
Then I ran logrorate -d app.conf
and it doesn't appear in logrotate status as well as no change in the debug file.
Is there anything like - rotation only will happen in files inside /var/log?
I know this is a bit of necromancy, but for the hundreds that bump on this, I did a working log rotation scheme on worpress -ubuntu 22-
sudo nano /etc/logrotate.d/wordpress
And include there the logrotate commands, I used those:
/var/www/<WPsite>/wp-content/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 666 <user> <group>
}
Tested with:
sudo logrotate -d -f /etc/logrotate.conf
Works OK:
rotating log /var/www/<WPSITE>/wp-content/debug.log, log->rotateCount is 14
dateext suffix '-20221129'
glob pattern '-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'
previous log /var/www/<WPSITE>/wp-content/debug.log.1 does not exist
renaming /var/www/<WPSITE>/wp-content/debug.log.14.gz to /var/www/<WPSITE>/wp-content/debug.log.15.gz (rotatecount 14, logstart 1, i 14),
renaming /var/www/<WPSITE>/wp-content/debug.log.13.gz to /var/www/<WPSITE>/wp-content/debug.log.14.gz (rotatecount 14, logstart 1, i 13),
renaming /var/www/<WPSITE>/wp-content/debug.log.12.gz to /var/www/<WPSITE>/wp-content/debug.log.13.gz (rotatecount 14, logstart 1, i 12),
renaming /var/www/<WPSITE>/wp-content/debug.log.11.gz to /var/www/<WPSITE>/wp-content/debug.log.12.gz (rotatecount 14, logstart 1, i 11),
renaming /var/www/<WPSITE>/wp-content/debug.log.10.gz to /var/www/<WPSITE>/wp-content/debug.log.11.gz (rotatecount 14, logstart 1, i 10),
renaming /var/www/<WPSITE>/wp-content/debug.log.9.gz to /var/www/<WPSITE>/wp-content/debug.log.10.gz (rotatecount 14, logstart 1, i 9),
renaming /var/www/<WPSITE>/wp-content/debug.log.8.gz to /var/www/<WPSITE>/wp-content/debug.log.9.gz (rotatecount 14, logstart 1, i 8),
renaming /var/www/<WPSITE>/wp-content/debug.log.7.gz to /var/www/<WPSITE>/wp-content/debug.log.8.gz (rotatecount 14, logstart 1, i 7),
renaming /var/www/<WPSITE>/wp-content/debug.log.6.gz to /var/www/<WPSITE>/wp-content/debug.log.7.gz (rotatecount 14, logstart 1, i 6),
renaming /var/www/<WPSITE>/wp-content/debug.log.5.gz to /var/www/<WPSITE>/wp-content/debug.log.6.gz (rotatecount 14, logstart 1, i 5),
renaming /var/www/<WPSITE>/wp-content/debug.log.4.gz to /var/www/<WPSITE>/wp-content/debug.log.5.gz (rotatecount 14, logstart 1, i 4),
renaming /var/www/<WPSITE>/wp-content/debug.log.3.gz to /var/www/<WPSITE>/wp-content/debug.log.4.gz (rotatecount 14, logstart 1, i 3),
renaming /var/www/<WPSITE>/wp-content/debug.log.2.gz to /var/www/<WPSITE>/wp-content/debug.log.3.gz (rotatecount 14, logstart 1, i 2),
renaming /var/www/<WPSITE>/wp-content/debug.log.1.gz to /var/www/<WPSITE>/wp-content/debug.log.2.gz (rotatecount 14, logstart 1, i 1),
renaming /var/www/<WPSITE>/wp-content/debug.log.0.gz to /var/www/<WPSITE>/wp-content/debug.log.1.gz (rotatecount 14, logstart 1, i 0),
log /var/www/<WPSITE>/wp-content/debug.log.15.gz doesn't exist -- won't try to dispose of it
renaming /var/www/<WPSITE>/wp-content/debug.log to /var/www/<WPSITE>/wp-content/debug.log.1
creating new /var/www/<WPSITE>/wp-content/debug.log mode = 0666 uid = 1001 gid = 1003
switching euid from 0 to 0 and egid from 4 to 0 (pid 119221)
logrotate on ubuntu is controlled by cron.daily which is launched at 6.25 UTC by the main crontab