I am trying to get logrotate to work on my VPS to rotate my apache files weekly. Currently the contents of the apache2 config file is as such.
"/var/www/user/site.com/logs/*.log" {
weekly
missingok
rotate 8
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/apache2 reload > /dev/null
endscript
}
I've left it for two weeks now and nothing has changed as far as I can tell. When I simulate it from the command line I get the following output.
user@geneva:/var/lib/logrotate$ /usr/sbin/logrotate -d /etc/logrotate.d/apache2
reading config file /etc/logrotate.d/apache2
reading config info for "/var/www/user/site.com/logs/*.log"
Handling 1 logs
rotating pattern: "/var/www/user/site.com/logs/*.log" weekly (8 rotations)
empty log files are not rotated, old logs are removed
considering log /var/www/user/site.com/logs/access.log
log does not need rotating
considering log /var/www/user/site.com/logs/error.log
log does not need rotating
not running postrotate script, since no logs were rotated
Any ideas as to what Iv'e configured wrong?
My status file is empty too :(
user@geneva:~$ cat /var/lib/logrotate/status
logrotate state -- version 2
Update
I deleted the status file and did a force run of logrotate and now the logs look like they have been rotated and the status file looks more promising!
sudo rm /var/lib/logrotate/status
sudo /usr/sbin/logrotate -f /etc/logrotate.conf
/var/lib/logrotate.statuswith a date at least a week old. I updated the answer with an example... – Tom May 11 '12 at 20:36#!/bin/sh
test -x /usr/sbin/logrotate || exit 0
– Malachi May 24 '12 at 19:59-d is dry-run. Thelogrotateman page is confusing when it says:-d, --debug ... Turns on debug mode and implies -v. This de-emphasizes the more important side-effect of not actually running. – arielf Feb 09 '20 at 22:53