Recall & Review
beginner
What is log rotation in the context of nginx?
Log rotation is the process of renaming and archiving old log files and creating new ones to prevent logs from growing too large and consuming too much disk space.
Click to reveal answer
beginner
Which tool is commonly used to automate log rotation for nginx logs on Linux systems?
The
logrotate tool is commonly used to automate log rotation for nginx logs on Linux systems.Click to reveal answer
intermediate
What is the purpose of the
postrotate script in a logrotate configuration for nginx?The
postrotate script runs commands after rotating logs, usually to tell nginx to reopen its log files so it writes to the new log files.Click to reveal answer
intermediate
Show a simple logrotate configuration snippet for nginx access logs.
Example configuration:
/var/log/nginx/access.log {
daily
missingok
rotate 7
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
postrotate
systemctl reload nginx > /dev/null 2>&1 || true
endscript
}Click to reveal answer
beginner
Why is it important to reload or restart nginx after log rotation?
Reloading nginx after log rotation makes nginx close the old log files and open new ones, so it continues logging correctly without losing data.
Click to reveal answer
What does the
rotate 7 directive mean in a logrotate config?✗ Incorrect
The
rotate 7 directive means to keep 7 old log files before removing the oldest.Which command is typically used inside
postrotate to reload nginx?✗ Incorrect
The command
systemctl reload nginx tells nginx to reload its configuration and reopen log files.What happens if nginx is not reloaded after log rotation?
✗ Incorrect
Without reload, nginx keeps writing to the old (rotated) log files, which can cause confusion and disk space issues.
Which of these is NOT a common logrotate option?
✗ Incorrect
There is no
restart option in logrotate; reloading or restarting services is done in scripts like postrotate.Where are nginx log files usually located on a Linux system?
✗ Incorrect
Nginx log files are typically stored in
/var/log/nginx/.Explain how log rotation works for nginx logs and why it is important.
Think about what happens when logs grow too big and how nginx handles log files.
You got /4 concepts.
Describe a basic logrotate configuration for nginx logs including key directives and scripts.
Focus on the main parts of a logrotate config and how it interacts with nginx.
You got /5 concepts.