logrotate configuration
Topic: Monitoring basics
Summary
Configure logrotate to rotate application or system logs by size or date. Prevents disk full. Use when logs grow without bound.
Intent: How-to
Quick answer
- Add file in /etc/logrotate.d/. Specify path, size or daily, rotate count, compress.
- Test with logrotate -d and logrotate -f. Cron runs logrotate daily.
- Use postrotate to tell app to reopen log file.
Prerequisites
Steps
-
Config file
Create file in /etc/logrotate.d/. Set path, size or daily, rotate, compress.
-
Postrotate
Add postrotate script if app must reopen log.
-
Test
Run logrotate -d then -f. Check files.
Summary
Add logrotate config. Postrotate if needed. Test.
Prerequisites
Steps
Step 1: Config file
Create config in /etc/logrotate.d/.
Step 2: Postrotate
Postrotate script for app reopen.
Step 3: Test
Dry run and force. Check files.
Verification
- Logs rotate. Disk stable.
Troubleshooting
No rotate — Check path and cron. App loses log — Use postrotate.