Managing Large Log Files

Enjoying a sunny Sunday out of town and unexpectedly you get an alert on your cell phone conveying a message that something is not correct with your dedicated server. Suddenly, you get panic and starts your desktop computer, laptop to log into your web server via SSH and starts looking around and a system log file attracts your attention because of the tremendous size in Gigabytes.

Firstly, never get panic in any situation. Getting panicked won’t solve your problem. Whenever a system log file increases tremendously, it indicates that there is something incorrect with the associated softwares or applications, but may be not that much serious you are thinking. Normally, the problem can be detected very easily simply by looking at the latest activities in the system log file. After logging into your dedicated server hosting via SSH, enter the following command:

tail /var/log/logfile-name

If the issue is not encounter from the latest activies, you can go through the complete log file for hints:

less /var/log/logfile-name

If the same issue is repeating, search for the repeated messages in the log file. Most of the time, its an error message, but can also be a warning to disable something by which its causing. Sometimes, it may be an intrusion attack, which you can check in to the security log file.

Once the problem is encountered, fix it and clear the log file and start with an expty one. Continuing the same large log file will consume much space. Enter the following command:

logrotate -v -f /etc/logrotate.d/logname

The above command will archived the old log file, and creates a new empty log file for further use.

Powered by BetterDocs