Do not report an error when a log is missing, and skip rotation when it exists but is empty.
Which directive combination is appropriate?
missingok tolerates a missing file and notifempty skips rotation of an empty file.
Detailed explanation
nomissingok / ifemptyIncorrect. nomissingok treats missing files as errors and ifempty rotates empty files.
Incorrect. nomissingok treats missing files as errors and ifempty rotates empty files.
missingok / ifemptyIncorrect. ifempty still rotates an empty file.
Incorrect. ifempty still rotates an empty file.
nomissingok / notifemptyIncorrect. It still errors when the file is missing.
Incorrect. It still errors when the file is missing.
missingok / notifemptyCorrect. It allows absence and skips empty logs.
Correct. It allows absence and skips empty logs.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' missingok notifemptyExpected result
missingokとnotifemptyKey points
- missingok tolerates missing
- notifempty skips empty
- Evaluate each directive separately
Notes
- Environment: printf / ログ変更なし
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.