Reputation: 71
logrotate is not rotating my logs
To verify that the logfile is not empty:
# ls -laFh /var/log/cisco-meraki.log
-rw-r----- 1 root adm 2.8G Sep 5 13:23 /var/log/cisco-meraki.log
Configuration (/etc/logrotate.d/zzzzz_default):
"/var/log/cisco-meraki.log" {
daily
rotate 10
compress
missingok
notifempty
create
}
Global config (logrotate.conf):
daily
rotate 10
create
include /etc/logrotate.d
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
Trying a manual run:
# logrotate --verbose -d zzzzz_default
reading config file zzzzz_default
Handling 1 logs
rotating pattern: "/var/log/cisco-meraki.log" after 1 days (10 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/cisco-meraki.log
log does not need rotating
To verify that the problem is not "allready rotated" I checked:
# cat /var/lib/logrotate/status|grep cisco
"/var/log/cisco-ace.log" 2016-1-19-16:0:0
"/var/log/cisco-pix.log" 2016-1-19-16:0:0
"/var/log/cisco-acs.log" 2016-1-19-16:0:0
"/var/log/cisco-asa.log" 2016-1-19-16:0:0
"/var/log/cisco-router.log" 2016-9-6-0:1:1
"/var/log/cisco-ips.log" 2016-1-19-16:0:0
..but no cisco-meraki.log
Upvotes: 7
Views: 13300
Reputation: 21
I encountered the same problem, and finally found that it was a file permission problem, the configuration file must be set to root, and then use su in the configuration file.
sudo chown root:root /etc/logrotate.d/xxx
/var/log/xxx.log {
su ec2-user ec2-user
daily
rotate 10
compress
missingok
notifempty
create 644 ec2-user ec2-user
}
if /etc/logrotate.d/xxx
owner is ec2-user:ec2-user, execute
sudo logrotate -f /etc/logrotate.d/xxx
nothing happened.
Upvotes: 0
Reputation: 11406
see https://unix.stackexchange.com/a/96947
Lets say you created your zzzzz_default file today. logrotate will create an entry, as if it rotated the logs today in /var/lib/logrotate/status.
When you run logrotate --verbose -d zzzzz_default
today
logrotate checks the last time it rotated logs reading /var/lib/logrotate/status. It will find that entry it created before so it will say log does not need rotating
If you run logrotate --verbose -d zzzzz_default
tomorrow
logrotate checks the last time it rotated logs reading /var/lib/logrotate/status. It will not find that entry so it will rotate the log files.
Upvotes: 4
Reputation: 41
From logrotate man page:
-d, --debug
Turns on debug mode and implies -v. In debug mode, no
changes will be made to the logs or to the logrotate
state file.
I was hit with exactly the same issue !
N.
Upvotes: 4