Configure logrotate for weekly rotation, four generations, and compression of old logs.
Which directives are required?
weekly sets frequency, rotate 4 sets retained generations, and compress enables compression.
Detailed explanation
daily / rotate 1 / nocompressIncorrect. It is daily, one generation, and explicitly disables compression.
Incorrect. It is daily, one generation, and explicitly disables compression.
monthly / rotate 4 / delaycompressIncorrect. It rotates monthly and does not enable compression itself.
Incorrect. It rotates monthly and does not enable compression itself.
weekly / rotate 4 / compressCorrect. These directives match all three requirements.
Correct. These directives match all three requirements.
weekly / size 4 / compressIncorrect. size 4 is not a generation count and has no appropriate unit.
Incorrect. size 4 is not a generation count and has no appropriate unit.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s\n' '/var/log/app.log {' ' weekly' ' rotate 4' ' compress' '}'Expected result
weekly、rotate 4、compressを含む合成blockKey points
- Frequency
- Retention count
- Compression
Notes
- Environment: 合成logrotate blockの表示のみ
- 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.