Bug 57388 - Need option like sharedscripts but that runs only if at least one log is rotated.
Need option like sharedscripts but that runs only if at least one log is rota...
Product: Red Hat Linux
Classification: Retired
Component: logrotate (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Elliot Lee
Aaron Brown
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2001-12-11 09:58 EST by John Dalbec
Modified: 2007-04-18 12:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2004-06-28 13:20:48 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description John Dalbec 2001-12-11 09:58:07 EST
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-18 19:03:29 EST
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-09 20:06:04 EDT
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 {
        echo    $1      >>/var/state/logrotate/syslog

/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.
        /bin/killall -HUP syslogd
        for f in `cat $1`; do
            case $f in

                # special stuff to parse kernel.log.1 (AKA $f.1) here ...


Comment 3 John Dalbec 2002-04-11 10:59:04 EDT
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 02:41:23 EDT
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 16:23:43 EDT
Send patches

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