Bug 57388 - Need option like sharedscripts but that runs only if at least one log is rotated.
Summary: Need option like sharedscripts but that runs only if at least one log is rota...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: logrotate
Version: 7.1
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Elliot Lee
QA Contact: Aaron Brown
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2001-12-11 14:58 UTC by John Dalbec
Modified: 2007-04-18 16:38 UTC (History)
0 users

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2004-06-28 17:20:48 UTC
Embargoed:


Attachments (Terms of Use)

Description John Dalbec 2001-12-11 14:58:07 UTC
I would like to request an option that acts like sharedscripts but doesn't run the scripts if no logs are to be rotated.
I would use this to run a Perl script that looks for Code Red/Nimda/etc. signatures in access_log before rotating it.
Since the latest apache version uses the sharedscripts option in /etc/logrotate.d/apache, I get a report every day instead of once a week.
I can (and have) split off access_log into its own section, but then I'm HUPping apache twice rather than once.
It would be more efficient to have an option (say "sharedscriptsonlyifrotate") as described above.  I could even deal with an option that 
always runs the prerotate but only runs the postrotate if a log was rotated (which I suspect is easier to program).

Comment 1 Elliot Lee 2001-12-19 00:03:29 UTC
Sounds like a nice idea. Unfortunately, since logrotate is at the bottom of the
food chain, I'm not likely to be able to implement it in this lifetime. "Patches
welcome", or something - perhaps asking on redhat-devel-list might find a
volunteer to write the patch.

Comment 2 Dean K. Gibson 2002-04-10 00:06:04 UTC
Apparently a common desire for logrotate is to have a bunch of log files that 
one wishes to rotate (e.g., from syslogd), but only SIGHUP syslogd when one or 
more files need rotating.  I offer the following scripts (as part of a 
logrotate config file) that not only do the job, but allow custom processing of 
some of syslogd's files without SIGHUPing syslogd multiple times.  This uses an 
undocumented feature of logrotate to pass the rotated file name to the script 
as the first ($1) parameter;

/var/log/syslog/*.log {
    prerotate
        echo    $1      >>/var/state/logrotate/syslog
    endscript
}

/var/state/logrotate/syslog {
    daily          # MUST be daily, as logs can rotate any day of the week
    rotate      1  # (or zero, or any other number)
    notifempty     # This is the key to only running if rotation occurred.
    prerotate
        /bin/killall -HUP syslogd
        for f in `cat $1`; do
            case $f in

            /var/log/syslog/kernel.log)
                # special stuff to parse kernel.log.1 (AKA $f.1) here ...
                ;;

            esac
        done
    endscript
}



Comment 3 John Dalbec 2002-04-11 14:59:04 UTC
Does logrotate always process logs in the order listed?  In what order are the /etc/logrotate.d files processed?

Comment 4 Dean K. Gibson 2002-04-13 06:41:23 UTC
Logrotate processes logrotate config files in the order it finds them in 
the /etc/logrotate.d directory (which can appear random), but within a lorotate 
config file, the actions are processed in order of specification (according to 
my reading of the code, my experience, and the assurance of ewt @redhat.com -- 
the original author of logrotate).


Comment 5 Elliot Lee 2002-04-15 20:23:43 UTC
Send patches


Note You need to log in before you can comment on or make changes to this bug.