Web Hosting Talk







View Full Version : Apache stops after logrotate!


zappp
01-15-2004, 07:14 PM
Ok, here is my problem.
Recenty I setuped logrotate twice per day: at 5am and 5pm.

Here is an apache logrotate config:

/home/www/www1/logs/access_log {
size 100M
nocompress
rotate 2
postrotate
/bin/kill -HUP `cat /usr/local/apache/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}


in the morning it works fine: rotate logs and apache still working. but in the evening... it is still rotate the logs (access_log->access_log.1), created access_log with zero size and nothing else: apache is not working. I am seeing one apache process but when I'm trying to open site through browser it wont work.


ofcourse the first thing I tried is to restart apache:

/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl stop: httpd stopped

/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl start: httpd (pid 991) already running

so it wont work either.

it start working when i manually killing this one httpd process and doing apachectl stop, start again.

So what should I do to not crashing apache after logrotate?

Thanks!

demonmoo
01-15-2004, 07:20 PM
It would help if you could post your logs here (errors messages are very usefull for this kind of thing) .
As a note I think this should be in the technical/security issues forum.

pmak0
01-16-2004, 01:18 PM
/usr/local/apache/bin/apachectl stop
/usr/local/apache/bin/apachectl stop: httpd stopped

/usr/local/apache/bin/apachectl start
/usr/local/apache/bin/apachectl start: httpd (pid 991) already running

That happens if you don't wait long enough after stopping Apache before starting it again, because when it says "httpd stopped" it actually means "httpd is stopping, but might not be stopped yet". If you get "httpd already running", simply keep typing "/usr/local/apache/bin/apachectl start" until it says "httpd started".

As for your logrotate configuration, try replacing the postrotate...endscript part with this; it works for me:

postrotate
/usr/local/apache/bin/apachectl restart > /dev/null
endscript

volfman
01-16-2004, 01:51 PM
Or better yet, use apachectl graceful instead of apachectl restart

zappp
01-18-2004, 09:41 AM
volfman, thanks for your suggestion.
i put apachectl graceful and that worked!