WebHostGear.com - the hosting resource for professionalshosting tutorials 
hosting howto webhost guide server managementJuly 25, 2008
server management, apache tutorials, hosting tutorials, cpanel, server security
Home / Hosting Tutorials / cPanel Tutorials / Fix Log Rotation Problems

Fix Log Rotation Problems



Printer Friendly Printer Friendly Send to a friend Send to a friend
By : Jon Rating : Average Rating : 9.84 From 19 Voter(s)

Since the beginning of time, cPanel has had logs that it simply does not rotate properly. Why this has been an ongoing problem that has never been fixed is beyond me, but it CAN be fixed and we'll go through what is needed to accomplish this.

The most important logs that are missed are the Apache system logs that are located in /usr/local/apache/logs. SSH into your server as root.

pico /etc/logrotate.d/httpd
(on some servers this file is called apache)

The first line should read:

/usr/local/apache/logs/*log {

Also you need to change the line that reads:

/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true

to:

/bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
(the above line should all be on ONE LINE!)

The next log file that needs to be dealt with is /var/log/xferlog.  This is your FTP transfer log.

pico /etc/logrotate.d/ftp

This will create a new file.  If you are running ProFTP, paste the following snippet into this file:


Article provided by WebHostGear.com
/var/log/xferlog {
postrotate /bin/kill -HUP `cat /var/proftpd.pid 2> /dev/null` 2> /dev/null || true
endscript
missingok
}



Article provided by WebHostGear.com

If you are running PureFTP then paste this into the file:

/var/log/xferlog {
postrotate /bin/kill -HUP `cat /var/run/pure-ftpd.pid 2> /dev/null` 2> /dev/null || true
endscript
missingok
}

The next item we need to deal with is for any sites for which you have installed SSL certificates for.  If you have not installed any SSL certificates, then you can skip this section.  Any domain that you have installed an SSL certificate for gets a log file for tracking SSL traffic and it is located in /var/log.  These are pretty simple to add.

pico /etc/logrotate.conf

Add an entry styled like the one below for each secure domain you have on your server at the end of the file:

/var/log/securedomain.tld {
weekly
rotate 1
}

Take a look in /var/log to make sure that you have the proper filename i that first line.  It will match exactly as you have it set up in WHM.

One other stray log that cPanel ignores is /var/log/chkservd.log.  Add this section to the same file (/etc/logrotate.conf) that you were just editing:

/var/log/chkservd.log {
weekly
rotate 1
}

To add insult to injury, cPanel is not rotating its own logs either.  Place this in the same file we have been editing:

/usr/local/cpanel/logs/stats_log {
weekly
rotate 1
}

/usr/local/cpanel/logs/access_log {
weekly
rotate 1
}

/usr/local/cpanel/logs/error_log {
weekly
rotate 1
}

That is all the logs in my systems that I found that were not getting rotated.  Armed with this information you should be able to rotate nearly any log, but if you do find some more, please drop me a line so I can update the article.

New! - Need server help? Hire an Expert

Get professional help with your configuration, script installation or server issue.
Learn how we can help you with any server problem and make your server run like new. Professional staff will contact you, after submitting a quote request, by phone or email.

Rate this Article :

1

2

3

4

5

6

7

8

9

10
Poor Excellent
Sources
Original post by Aussie from EV1 Forums, updated to present day information.

Related Articles


» Official Cpanel Newbie Guide
» Setting up Private Nameservers in Cpanel
» Accepting Credit Cards Online with Third-party Merchant Accounts
» Server Loads Explained
» Apache Log Files Explained
» Affordable is many times more than the price tag
» How to turbo charge your sales calls
» Rkhunter Installation


Discuss this article with others in our new hosting forums

Comments / Feedback

Nicholas Tritchew
For the: Home / Hosting Tutorials / Cpanel Tutorials / Fix Log Rotation Problems

I was curious if this log rotate procedure outlined deletes the previous log files when it rotates.

Or does it compress the previous log, stores it in a archive folder, and then creates a new log?

-Nicholas
Vince
Hi,

Prior that you mention this:
"but if you do find some more, please drop me a line so I can update the article."

We have a file xferlog in our /var/log directory.

/var/log/xferlog
This is about 8MB now.

Can we apply the log rotate which you have provide in http://www.webhostgear.com/144.html

pico /etc/logrotate.conf
add the below entry:

/usr/local/cpanel/logs/error_log {
weekly
rotate 1
}

Thanks for your advise.
Sincerely,
Vincent Kam


Diana Ward
You are quickly becoming my guru! Thank you!
tc
i use cpanel and the logs for my websites are located at: /usr/local/apache/domlogs/

They are getting rotated. I'm not sure how but they all go back to January 31 and today is February 22. 2006.

This article is old, maybe its out of date as cPanel has gone through a lot of updates. So I'm posting this comment to let others know things may be different.
Flash Alexander
The first instruction refers to apache 'system' logs. Therefore I read it to not cover the 'domlogs'.

Should I also include a line for the domlogs?

 Add Comment
Name
Email
Image Code
Refresh Image

Comments / Feedback



Web Hosting News RSS ?


WebHostGear Hire an Expert - NEW!
Let us improve your servers performance, find that spammer and take care of that kernel upgrade. Hire us to help with any tutorials listed on the site or any other services needed. Get your free, NO obligation quote now

Our site offers free hosting tutorials, cpanel tutorial, web hosting news, shell commands, running a web hosting business, dedicated guides, linux tutorial, apache install, home web server, web server guide, ssh commands, dedicated servers, DNS nameservers, chkrootkit, apf firewall, exim configuration, server compromised, cron backup solution, ftp backup script

Server Tutorials


WebHostGear Reviewed by Ping Zine - Click here

Special Offer:


Links:
cPanel server administration

MidPhase Coupons

Reseller Hosting

Reseller Hosting FAQ

Icon

Web Hosting

Datacenter Discussion Forum

Lunarpages Coupon

Hosting Coupon



WebhostGear Sponsors
Going Up Advertise Hosting Free Uptime Check Web Hosting Chat Icons Banners Mall