[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Logrotate with httpd

Posted on 2009-05-16
1
Medium Priority
?
753 Views
Last Modified: 2013-12-16
Hi,

Got a CentOS webserver hosting around 150 websites and each of their apache log files (access_log, error_log, combined_log) were saved separately (/var/log/site1, /var/log/site2 and so on). The previous administrator didn't setup the logrotate for these logfiles, so some were almost 15Gb of file size and delete them manually. Another thing is, the httpd are having problem restarting and even stopping the service. most of the time, it failed to stop and start which I need to do kill or killall each processes manually.

What I wish to do is to set all sites logs with logrotate monthly (4 logs  + 1 current) but making sure that when the httpd (apache2) got restarted, it will surely run again.

Below is the example I found but from a debian website (http://www.debian-administration.org/articles/117) but not sure what needs to modify to meet my requirements.

Thanks
/var/log/apache/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if [ -f /var/run/apache.pid ]; then
                        /etc/init.d/apache restart > /dev/null
                fi
        endscript
}

Open in new window

0
Comment
Question by:Raleigh Guevarra
1 Comment
 
LVL 7

Accepted Solution

by:
darrickhartman earned 2000 total points
ID: 24403290
By default, CentOS uses /var/log/httpd/* for log file locations.  I'd suggest making changes to your apache configuration files to direct the sites to use that location for logging.  There are reasons why standards are established.

If Apache doesn't stop, there is a reason.  I'd suggest issuing 'service httpd stop' then waiting 10 seconds and verifying that all httpd processes are stopped.  If not, look in the error log files to find out why.  

Also the default /etc/logrotate.d/httpd file should contain the following:

/var/log/httpd/*log {
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
The purpose of this article is to show how we can create Linux Mint virtual machine using Oracle Virtual Box. To install Linux Mint we have to download the ISO file from its website i.e. http://www.linuxmint.com. Once you open the link you will see …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question