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.
weekly / rotate 4Correct. It requests weekly rotation and four generations.
weekly / rotate weeklyIncorrect. rotate requires an integer count.
monthly / rotate 4Incorrect. 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
Syslog facility and priority
Metadata that classifies a message source and its severity.
Journal persistence
Whether systemd journal data survives a reboot and where it is stored.
Log rotation
A process that retains, renames, compresses, or removes log generations.