Solved

Logrotate with httpd

Posted on 2009-05-16
1
702 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now