LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   logrotate ignoring 'size' spec ... why? (https://www.linuxquestions.org/questions/linux-software-2/logrotate-ignoring-size-spec-why-492899/)

OpenMacNews 10-16-2006 01:25 PM

logrotate ignoring 'size' spec ... why?
 
Code:

hi,

i've built and installed LOGROTATE v3.7.4-7 from a src tarball, extracted via rpm2cpio from:

http://download.fedora.redhat.com/pub/fedora/linux/core/development/source/SRPMS/logrotate-3.7.4-7.src.rpm


my lograte.conf includes:

        ====================================
        compresscmd /usr/bin/gzip
        uncompresscmd /usr/bin/gunzip
       
        /var/log/test.log {
                size 3M
                daily
                maxage 30
                rotate 30

                create 640 devuser devgrp
                dateext

                missingok
                notifempty
                sharedscripts

                postrotate
                        kill -HUP `cat /var/process/exim/exim.pid 2>/dev/null` 2> /dev/null || true
                endscript
       
                nomail
                nocompress
        }
        ====================================

currently, test.log is > 3M in size:

        % ls -al /var/log/test.log
                -rw-r----- 1 devuser devgrp 22782552 Oct 16 10:20 test.log

my GOAL, with the above conf, is to exec logrotate hourly, via a cronjob and have it rotate test.log 'only' once daily, UNLESS the log files has exceeded 3M, then rotate immediately ...

but, when i exec logrotate, i get:

        "empty log files are not rotated, only log files >= 3145728 bytes are rotated, old logs are removed.
       
        considering log /var/log/test.log.
       
        log does not need rotating"

and, test.log is NOT rotated.

what am i config'ing wrong here?

thanks,

richard


bigrigdriver 10-16-2006 01:58 PM

Quote:

% ls -al /var/log/test.log
-rw-r----- 1 devuser devgrp 22782552 Oct 16 10:20 test.log
It does not appear that you are doing anything wrong. Either the log will rotate when the size exceeds 3M (which it has not done), or it will rotate at the end of the day (which has not yet occured).

Look at the file size and time stamp on the output of your 'ls -al' command.

OpenMacNews 10-16-2006 02:47 PM

hi bigrigdriver,

Quote:

Originally Posted by bigrigdriver
It does not appear that you are doing anything wrong. Either the log will rotate when the size exceeds 3M (which it has not done), or it will rotate at the end of the day (which has not yet occured).


Code:

argh!  bits-n-bytes ...

ok, so file_sz(22784640) = 2.72 M

fair point.

changing to:

  % grep size logrotate.conf
      size 1M

where "22784640" _is_ > 1M,

on execute of logrotate, i *still* get:

      "empty log files are not rotated, only log files >= 1048576
      bytes are rotated, old logs are removed considering log
      /var/log/test.log
      log does not need rotating"

Quote:

Look at the file size and time stamp on the output of your 'ls -al' command.
that's clear -- but should be (?) irrelevant, as 'size' spec is *supposed* to override 'daily' .... no?

cheers,

richard

bigrigdriver 10-16-2006 07:35 PM

From the logrotate man pages:

Quote:

Normally, logrotate is run as a daily cron job. It will not modify a log multiple
times in one day unless the criterium for that log is based on the log's size and
logrotate is being run multiple times each day, or unless the -f or -force option
is used.
That's just vague enough to have me wondering if size and daily are mutually exclusive for proper operation of logrotate. Which has priority over the other? Normally, it's run as a daily rotation. If size is specified and daily is also specified, will size spec work? I don't know.

In your case, obviously it isn't working. Try re-ordering the specs. Put size somewhere after daily, then try again. Or, remove the daily spec to see if it works with a size spec.

OpenMacNews 10-16-2006 07:50 PM

hi again,

Quote:

Originally Posted by bigrigdriver
That's just vague enough

hehe! accident? i don't THINK so! :-p

Quote:

Originally Posted by bigrigdriver
to have me wondering if size and daily are mutually exclusive for proper operation of logrotate. Which has priority over the other? Normally, it's run as a daily rotation. If size is specified and daily is also specified, will size spec work? I don't know.

In your case, obviously it isn't working. Try re-ordering the specs. Put size somewhere after daily, then try again. Or, remove the daily spec to see if it works with a size spec.

so far, no effect as a result of reordering.

REMOING the "daily" spec, DOES get the "size" spec working as expected -- but of source, one loses the once-per-day capability.

and, of course, 'daily' without 'size' works too.

all that said, my workaround for the moment is TWO cron jobs, with two different .conf files. One, running once a day, with a "daily" spec, and one running, say, hourly, with a "size" spec.

not optimal, and certainly NOT the wasy one would hope presume it works, but oh well.

i've been looking around for better-behaved, well-supported rotate progs/scripts .. haven't found one (yet). thinking of simply (well, not exactly ...) writing my own.

cheers,

richard


All times are GMT -5. The time now is 09:06 PM.