Challenge - 5 Problems
Log Rotation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Nginx logrotate configuration effect
Given this logrotate configuration snippet for nginx logs, what will happen after logrotate runs?
/var/log/nginx/*.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
postrotate
systemctl reload nginx > /dev/null 2>/dev/null || true
endscript
}Attempts:
2 left
💡 Hint
Look at the keywords 'daily', 'rotate 7', 'compress', and 'postrotate' commands.
✗ Incorrect
This configuration rotates nginx logs daily, keeps 7 old logs compressed (due to 'compress' and 'delaycompress'), and reloads nginx after rotation to reopen log files.
❓ Troubleshoot
intermediate2:00remaining
Nginx logs not rotating as expected
You configured logrotate for nginx logs but notice logs are not rotating daily as expected. Which of these is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the system is actually running the logrotate commands automatically.
✗ Incorrect
If the cron job or systemd timer that runs logrotate is not active, logs won't rotate regardless of configuration.
❓ Configuration
advanced2:30remaining
Configure logrotate to keep logs for 14 days and compress immediately
Which logrotate configuration snippet correctly rotates nginx logs daily, keeps 14 compressed old logs, and compresses logs immediately after rotation?
Attempts:
2 left
💡 Hint
Immediate compression means no 'delaycompress' option.
✗ Incorrect
Option D rotates daily, keeps 14 compressed logs, and compresses immediately because it lacks 'delaycompress'.
✅ Best Practice
advanced2:00remaining
Recommended action after log rotation for nginx
After rotating nginx logs, what is the recommended action to ensure nginx writes to new log files?
Attempts:
2 left
💡 Hint
Consider how nginx handles open file descriptors after log rotation.
✗ Incorrect
Reloading nginx causes it to reopen log files without stopping the service, which is best practice after log rotation.
🧠 Conceptual
expert2:30remaining
Understanding delaycompress in logrotate
What is the main reason to use the 'delaycompress' option in nginx logrotate configuration?
Attempts:
2 left
💡 Hint
Think about why you might want the newest rotated log to stay uncompressed temporarily.
✗ Incorrect
'delaycompress' keeps the most recent rotated log uncompressed until the next rotation, which helps processes that might still be writing or reading that file.