BuycPanel Blog

BuycPanel Blog

Latest news and updates

How do you Reduce the Size of Log Files that aren’t Managed

Posted by Allura on 17 05 2019.

A Brief Overview
The following document shall outline the steps to be followed to reduce the size of or clear log files that are not managed on one’s server using the WHM cPanel Log Rotation Configuration Interface.The steps should be performed only by experienced system administrators to prevent any accidental data loss, only qualified individuals should attempt the process.Note/Warning:The method described by the document herein is not guaranteed to work as it is of an experimental nature. 
Why does one need to Manage Log FilesBoth WHM and cPanel create and maintain log files as records.
The log files enable one to keep a tab on system operations and examine any errors arising in the same.
However, as the time period of their storage increased, the log files grow in size considerably taking up a significant amount of storage space on the system.
That is when they need to be reviewed and…

A Brief Overview

The following document shall outline the steps to be followed to reduce the size of or clear log files that are not managed on one’s server using the WHM cPanel Log Rotation Configuration Interface.

The steps should be performed only by experienced system administrators to prevent any accidental data loss, only qualified individuals should attempt the process.

Note/Warning:

The method described by the document herein is not guaranteed to work as it is of an experimental nature.

 

Why does one need to Manage Log Files

  • Both WHM and cPanel create and maintain log files as records.
  • The log files enable one to keep a tab on system operations and examine any errors arising in the same.
  • However, as the time period of their storage increased, the log files grow in size considerably taking up a significant amount of storage space on the system.
  • That is when they need to be reviewed and managed.

 

Checking the Disk Space Occupied by Log Files

To do this one has to run the ‘du’ command, after ensuring one is logged in as the root user.

du -h /var/log/

The ‘du’ command gives an estimate of the size and space occupied by each log file and directory along the specified path. In the above example the /var/log/ path respectively.

The ‘-h’ component of the command is ensures that the data is presented in a format humanly intelligible or readable.

 

Steps for Compressing or Deleting Log Files

Having checked the Disk Space occupied by log files one can either compress or delete the same.

Reducing Size of Log Files:

  • cPanel and WHM use the cpanellogd daemon to archive log files.
  • However, not all log files are archived and one can simply compress the un-archived log files in order to reduce the disk space occupied by them.

 

Deleting Log Files:

One may also choose to Delete files that are taking up an unnecessary amount of disk space, such as old archived log files. One has to:

  1. ‘Select’ the directories or the individual files within a directory that one has decided to ‘Clear’.
  2. ‘Empty’ the selected log files or directories using the ‘cat’ or ‘concatenate’ command –

cat /dev/null > munin-update.log

This command ensures therefore the deletion of the file data, retaining the file name.

Note:

One can also choose to Enable the cPanel or WHM Log Rotation system which helps to compress and then store old log files in the /usr/local/cpanel/logs/archive/ directory, aiding the process of managing and reducing disk space occupied.

 

Concluding Thoughts

One can choose to follow any one of the various methods outlined above in order to reduce the size of or manage Log Files.