Solved

Logrotate with httpd

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
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.
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.

809 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