How can I compress my cPanel domlogs log files?

Before setting up compression of your logs you will want to have cpanel run the stats as often as possible. This is so you do not miss any stats that would have been included were your logs not compressed before stats run.

To do this, login to WHM, and click on Tweak Settings under Server Configuration in the left menu. Scroll down to Stats and Logs, and then in the field next to "Number of days between processing log files and bandwidth usage (default 1, decimal values are ok):" enter '.5'.

This will cause your logs to be run twice a day, and should allow you to have up to date stats.

After doing this, we can begin to setup your domlogs compression. You will need to open an ssh shell to your server to complete this.

Change directories to /etc/logrotate.d/ and find the file named httpd. You will need to copy this file to a new file in the same directory:

root@cpdemo [/etc/logrotate.d]# cp httpd domlogs
root@cpdemo [/etc/logrotate.d]# ls -la domlogs
-rw-r--r-- 1 root root 390 Nov 8 21:26 domlogs
root@cpdemo [/etc/logrotate.d]#

Now you will want to edit your new file to contain the following:

/usr/local/apache/logs/*.com /usr/local/apache/logs/*.org /usr/local/apache/logs/*.net {
    missingok
    notifempty
    size=200M
    rotate 2
    compress
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

Just save your new file and you are done. Most linux distributions come default with a logrotate cronjob running nightly that will work with this configuration.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

cPanel FAQ

This is where you will find FAQ items relating to...

My server says my cPanel license is expired!

First, verify if this error is correct. Go to http://verify.cpanel.net and enter your server's...

How do I backup my entire site in cPanel?

Entire accounts can be backed up by doing the following: 1. Log into your cPanel and click the...

How do I upload and edit my files?

You can upload your files using FTP. You will need an FTP client (search on Google, there are...

How do I backup MySQL Databases in cPanel?

MySQL databases can be backed up by doing the following: 1. Log into your cPanel and click the...