Solved

Logrotate with httpd

Posted on 2009-05-16
1
712 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
1 Comment
 
LVL 7

Accepted Solution

by:
darrickhartman earned 500 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

860 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