Here, we cover the process when disk space on a server is full. In most cases, the log files may need to be trimmed to free up additional disk space.
Trimming log files from the top, as opposed to using the truncate operation, allows for the preservation of the most recent log entries, ensuring that critical and up-to-date information is retained for troubleshooting and analysis.
Trim Logs
IMPORTANT: This solution will require root access. If this needs to be obtained, follow the guide on requesting root access.
- SSHinto your server as the root user
- Identifythe log file to trim
- Use the command
df -hto confirm that the disk is reaching capacity - If no large folders are returned, run the command on the root directory / using
sudo du-tree
EXAMPLE: If/var/log/nginx/error.logwas found to be excessively large, you would want to trim this file. -
Trim the log file using the following command
fallocate -c -o 0 -l $size error.logREPLACE: $size with the amount to remove and error.log with the error log file.
EXAMPLE: To remove the first 34GB of a 35GB NGINX error log, you would runfallocate -c -o 0 -l 34G /var/log/nginx/error.log.
Comments
0 comments
Article is closed for comments.