I want to capture slow queries via logrotate
, and I want them to rotate weekly and I want to save a year's worth. The logs take the form:
-rw-r-----. 1 mysql root 1239 Feb 21 18:46 mysqld1-slow.log
-rw-r-----. 1 mysql root 885 Feb 11 14:48 mysqld2-slow.log
-rw-r-----. 1 mysql root 885 Feb 22 08:58 mysqld3-slow.log
-rw-rw-rw-. 1 mysql root 802 Feb 11 14:47 mysqld-slow.log
Because the logs end up being written to so frequently, how can I make sure nothing is missed by logrotate
? The process itself doesn't create the file, it needs to have the original there. I was thinking this would do it:
/var/log/mysqld*-slow.log {
missingok
notifempty
weekly
rotate 52
compress
delaycompress
create 0644 mysql root
}
So it should compress the old, and create the same filename with the right permissions, but I'm unsure how logrotate handles something that's written to amidst the movement.