A systems administrator is alerted that a critical Linux application server is running low on disk space on the root partition. Upon investigation, the administrator finds that a single log file, /var/log/app/application.log, has grown to over 100 GB. The administrator needs to implement a long-term, automated solution to prevent this from recurring while preserving recent log data for troubleshooting. Which of the following is the MOST effective solution?
Write a cron job that runs a script nightly to delete the application.log file.
Modify the application's configuration to send all log output to /dev/null.
Provision a larger disk for the server and move the /var/log directory to the new partition.
Configure a log rotation utility to schedule the regular archiving and compression of the log file.
The correct answer is to configure a log rotation utility. Log rotation is the standard and most effective method for managing log files that grow over time. This process automatically renames, compresses, moves, and eventually deletes old log files based on a defined schedule or size threshold. This prevents any single file from consuming all available disk space while preserving recent logs for analysis and compliance. Increasing the disk size is only a temporary fix and does not address the root cause of the uncontrolled log growth. Writing a script to simply delete the file would result in the loss of potentially critical troubleshooting data. Disabling logging entirely by redirecting output to /dev/null would solve the space issue but is a severe anti-pattern that would make future troubleshooting and security auditing impossible.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is log rotation and how does it work?
Open an interactive chat with Bash
How do `logrotate` configurations ensure better control of log files?
Open an interactive chat with Bash
Why is provisioning a larger disk not an ideal solution for log file management?