logrotate isn't rotating a particular log file (and i think it should be)

Posted by Max Williams on Server Fault See other posts from Server Fault or by Max Williams
Published on 2010-12-29T15:10:15Z Indexed on 2010/12/30 4:55 UTC
Read the original article Hit count: 301

Filed under:

Hi all. For a particular app, i have log files in two places. One of the places has just one log file that i want to use with logrotate, for the other location i want to use logrotate on all log files in that folder. I've set up an entry called millionaire-staging in /etc/logrotate.d and have been testing it by calling logrotate -f millionaire-staging.

Here's my entry:

#/etc/logrotate.d/millionaire-staging
compress
rotate 1000
dateext
missingok
sharedscripts
copytruncate

/var/www/apps/test.millionaire/log/staging.log {
  weekly
}

/var/www/apps/test.millionaire/shared/log/*log {
  size 40M
}

So, for the first folder, i want to rotate weekly (this seems to have worked fine). For the other, i want to rotate only when the log files get bigger than 40 meg. When i look in that folder (using the same locator as in the logrotate config), i can see a file in there that's 54M and which hasn't been rotated:

$ ls -lh /var/www/apps/test.millionaire/shared/log/*log
-rw-r--r-- 1 www-data root    33M 2010-12-29 15:00 /var/www/apps/test.millionaire/shared/log/test.millionaire.charanga.com.access-log
-rw-r--r-- 1 www-data root    54M 2010-09-10 16:57 /var/www/apps/test.millionaire/shared/log/test.millionaire.charanga.com.debug-log
-rw-r--r-- 1 www-data root    53K 2010-12-14 15:48 /var/www/apps/test.millionaire/shared/log/test.millionaire.charanga.com.error-log
-rw-r--r-- 1 www-data root   3.8M 2010-12-29 14:30 /var/www/apps/test.millionaire/shared/log/test.millionaire.charanga.com.ssl.access-log
-rw-r--r-- 1 www-data root    16K 2010-12-17 15:00 /var/www/apps/test.millionaire/shared/log/test.millionaire.charanga.com.ssl.error-log
-rw-r--r-- 1 deploy   deploy    0 2010-12-29 14:49 /var/www/apps/test.millionaire/shared/log/unicorn.stderr.log
-rw-r--r-- 1 deploy   deploy    0 2010-12-29 14:49 /var/www/apps/test.millionaire/shared/log/unicorn.stdout.log

Some of the other log files in that folder have been rotated though:

$ ls -lh /var/www/apps/test.millionaire/shared/log
total 91M
-rw-r--r-- 1 www-data root    33M 2010-12-29 15:05 test.millionaire.charanga.com.access-log
-rw-r--r-- 1 www-data root    54M 2010-09-10 16:57 test.millionaire.charanga.com.debug-log
-rw-r--r-- 1 www-data root    53K 2010-12-14 15:48 test.millionaire.charanga.com.error-log
-rw-r--r-- 1 www-data root   3.8M 2010-12-29 14:30 test.millionaire.charanga.com.ssl.access-log
-rw-r--r-- 1 www-data root    16K 2010-12-17 15:00 test.millionaire.charanga.com.ssl.error-log
-rw-r--r-- 1 deploy   deploy    0 2010-12-29 14:49 unicorn.stderr.log
-rw-r--r-- 1 deploy   deploy  41K 2010-12-29 11:03 unicorn.stderr.log-20101229.gz
-rw-r--r-- 1 deploy   deploy    0 2010-12-29 14:49 unicorn.stdout.log
-rw-r--r-- 1 deploy   deploy 1.1K 2010-10-15 11:05 unicorn.stdout.log-20101229.gz

I think what might have happened is that i first ran this config with a pattern matching *.log, and that means it only rotated the two files that ended in .log (as opposed to -log). Then, when i changed the config and ran it again, it won't do any more since it think's its already had its weekly run, or something.

Can anyone see what i'm doing wrong? Is it to do with those top folders being owned by root rather than deploy do you think?

thanks, max

© Server Fault or respective owner

Related posts about logrotate