Rotate /var/log/app.log weekly and retain four old generations.
Which directives are appropriate?
weekly sets the rotation interval and rotate 4 retains four generations.
Detailed explanation
daily / rotate 4Incorrect. It rotates daily rather than weekly.
Incorrect. It rotates daily rather than weekly.
weekly / rotate 4Correct. It requests weekly rotation and four generations.
Correct. It requests weekly rotation and four generations.
weekly / rotate weeklyIncorrect. rotate requires an integer count.
Incorrect. rotate requires an integer count.
monthly / rotate 4Incorrect. monthly uses a monthly interval.
Incorrect. monthly uses a monthly interval.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' weekly 'rotate 4'Expected result
weeklyとrotate 4Key points
- weekly is the interval
- rotate is a generation count
- Roughly four weeks retained
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.