Your Webhosting Questions
Answered by the Webhosting Experts

Compress cPanel domlogs


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:

< a href=”mailto:root@cpdemo">root@cpdemo [/etc/logrotate.d]# cp httpd domlogs
< a href=”mailto:root@cpdemo">root@cpdemo [/etc/logrotate.d]# ls -la domlogs
-rw-r–r– 1 root root 390 Nov 8 21:26 domlogs
< a href=”mailto:root@cpdemo">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 {
rotate 2
/bin/kill -HUP `cat /usr/local/apache/logs/ 2>/dev/null` 2> /dev/null || true

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. Should you need more information about logrotate, or it’s many options, merely view the man page.


Need More Personalized Help?

If you have any further issues, questions, or would like some assistance checking on this or anything else, please reach out to us from your account and provide your server credentials within the encrypted field for the best possible security and support.

If you are unable to reach your account or if you are on the go, please reach out from your valid account email to us here at: [email protected]. We are also available to you through our phone and live chat system 24/7/365.

Tags +