Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   CentOS (http://www.linux-archive.org/centos/)
-   -   Logrotate "firstaction" with non-0 exit status. Or: How to keep logrotate from rotating via scripts? (http://www.linux-archive.org/centos/709286-logrotate-firstaction-non-0-exit-status-how-keep-logrotate-rotating-via-scripts.html)

Toralf Lund 10-03-2012 11:03 AM

Logrotate "firstaction" with non-0 exit status. Or: How to keep logrotate from rotating via scripts?
 
Hi,

I'm wondering if anyone here has any experience with the "firstaction"
script in logrotate config files, or more specifically, the behaviour
with a non-0 exit status. The logrotate manpage says:

firstaction/endscript

The lines between firstaction and endscript (both of which must
appear on lines by themselves) are executed (using /bin/sh) once
before all log files that match the wildcarded pattern are rotated,
before prerotate script is run and only if at least one log will
actually be rotated.
These directives may only appear inside a log file definition. Whole
pattern is passed to the script as first argument. If the script
exits with error,
no further processing is done. See also lastaction.


My question is, what exactly does "no further processing is done" mean?
The obvious interpretation seems to be that the log file will not be
rotated, but based on tests I've done, this does not seem to be the
case. If I run logrotate with this config:

/tmp/testfile {
missingok
size 0
rotate 1000
copytruncate
firstaction
false
endscript
}

I get the message:

error: error running first action script for /tmp/testfile

But /tmp/testfile is still copied to /tmp/testfile.1 (provided that it
exists.) Then if I run again, I end up with /tmp/testfile,
/tmp/testfile.1 and /tmp/testfile.2, and so on...

Does this mean the manpage note must be interpreted differently? Or is
perhaps the behaviour buggy? And, is there any way at all I can use
commands in the config file to control whether the rotation is done or
not; this is what I'm looking for, really?

I've tested this on CentOS release 5.8...


- Toralf

This e-mail, including any attachments and response string, may contain proprietary information which is confidential and may be legally privileged. It is for the intended recipient only. If you are not the intended recipient or transmission error has misdirected this e-mail, please notify the author by return e-mail and delete this message and any attachment immediately. If you are not the intended recipient you must not use, disclose, distribute, forward, copy, print or rely on this e-mail in any way except as permitted by the author.
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


All times are GMT. The time now is 02:28 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.