Bug 5
Summary: | logrotate fails (unnecessarily) when prerotate script runs without effect | ||
---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | seth |
Component: | logrotate | Assignee: | David Lawrence <dkl> |
Status: | CLOSED NOTABUG | QA Contact: | |
Severity: | low | Docs Contact: | |
Priority: | low | ||
Version: | 5.2 | Flags: | chaowan:
needinfo-
|
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 1998-11-20 12:00:42 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
seth
1998-11-08 18:44:14 UTC
Two solutions: grep something filename >> output || exit 0 (i.e. grep succeeds, or 'exit 0' succeeds) or: grep something filename | cat >> output (the pipeline will ignore the exit status of grep, but will still report errors such as "no space left on device" or "permission denied" or "I/O error"). Perhaps the documentation should be updated. The principle of least surprise says that the established behavior shouldn't change. Ok...I looked in the source code. I can see starting line 395 if (runScript(log->files[logNum], log->pre)) { fprintf(errorFile, "error running prerotate script -- leaving old log in place\n"); hasErrors = 1; And RunScript() is returning the result from the system command. So presumably a grep that finds nothing is appearing to be an error. It has been a while since I have played with system() Isn't it possible to have more nuance in interpreting the kinds of errors? If not, then perhaps the man page should be modified to reflect this fact. by de facto standard, unix commands exit with a nonzero status when there has been an error. > by de facto standard, unix commands exit with a nonzero status
> when there has been an error.
True. But you do not seem to appreciate the point that the
manpage logrotate(1) does not inform what logrotates behavior will be
under those circumstances.
Here is the relevant piece:
prerotate/endscript
The lines between prerotate and endscript (both of
which must appear on lines by themselves) are exe-
cuted before the log file is rotated. These direc-
tives may only appear inside of a log file defini-
tion. See postrotate as well
Nowhere does it say "Failures will result in the non-execution of
the rotation" or warn that this also means that greps that return
nothing will count as a failure.
You can discard the issue if you want, but it is poor documentation,
especially when one considers the "typical" use of a prerotate
script would be pull out and save potentially interesting
things from a log file, and where one is likely to get a
grep that returns nothing.
Cheers,
Seth
|