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

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...

Error 550 – “The recipient cannot be verified”

On servers running cPanel, you may find that mail sent to valid users it bounced back by your...

Ports that must be open to run cPanel behind a firewall / IPTables

20 ftp tcp inbound/outbound21 ftp tcp,udp inbound/outbound22 ssh tcp inbound25 smtp tcp...

Quotas in WHM

ssh into the server then issue:/sbin/quotaoff -av/sbin/quotacheck -augvm/sbin/quotaon -av

Running exim on a different port

Log into WHM and click on "Service Manager" under the Service Configuration grouping....