Apache shutdown every Sunday

Most Sundays, one or more of our production servers stop serving webpages and when we investigate, apache is stopped. We restart apache and everything is fine until next week. We suspect the log rotation is the culprit. I've included a section of the log rotation page and the post rotation commands are interesting. Some are simple:

/var/log/virtualmin/bbexcavatinginc.com_error_log Weekly /usr/sbin/apache2ctl graceful

and others more complicated:

/var/log/virtualmin/earlywintersoutfitting.com_access_log

/var/log/virtualmin/earlywintersoutfitting.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi I'm wondering if our issue can be with the restart command in these more complicated postrotate commands and also if that /dev/null/fi , and apparently cut off command is not part of the problem.

Appreciate any help you can give here. Thanks, Jeff

We have around 130 servers on this box Here is part of the file:

/var/log/virtualmin/ajbrownandcompany.com_access_log

/var/log/virtualmin/ajbrownandcompany.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/aleccreighton.com_access_log /var/log/virtualmin/aleccreighton.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/anxietydream.com_access_log /var/log/virtualmin/anxietydream.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/arrowleafbistro.com_access_log /var/log/virtualmin/arrowleafbistro.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/bikemethow.com_access_log /var/log/virtualmin/bikemethow.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/boothcanyonorchard.com_access_log /var/log/virtualmin/boothcanyonorchard.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/carteblanchelandscape.com_access_log /var/log/virtualmin/carteblanchelandscape.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/earlywintersoutfitting.com_access_log /var/log/virtualmin/earlywintersoutfitting.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/friendsofbearcreek.com_access_log /var/log/virtualmin/friendsofbearcreek.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/cassiemarchbank.com_access_log /var/log/virtualmin/cassiemarchbank.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/practice-transitions.com_access_log /var/log/virtualmin/practice-transitions.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/practicetransitions.com_access_log /var/log/virtualmin/practicetransitions.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/rebelcows.com_access_log /var/log/virtualmin/rebelcows.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/turnsonadime.com_access_log /var/log/virtualmin/turnsonadime.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/valuestone.com_access_log /var/log/virtualmin/valuestone.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/balloonwinthrop.com_access_log /var/log/virtualmin/balloonwinthrop.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/firevisionllc.com_access_log /var/log/virtualmin/firevisionllc.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/dinobiris.com_access_log /var/log/virtualmin/dinobiris.com_error_log Weekly /usr/sbin/apachectl graceful /var/log/virtualmin/flcooley.com_access_log /var/log/virtualmin/flcooley.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/espritdecore.biz_access_log /var/log/virtualmin/espritdecore.biz_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/gardnergardens.com_access_log /var/log/virtualmin/gardnergardens.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/gp-designs.com_access_log /var/log/virtualmin/gp-designs.com_error_log Weekly /usr/sbin/apachectl graceful /var/log/virtualmin/gudrunbrunot.com_access_log /var/log/virtualmin/gudrunbrunot.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/hanksharvestfoods.com_access_log /var/log/virtualmin/hanksharvestfoods.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/hotelsateekhwa.com_access_log /var/log/virtualmin/hotelsateekhwa.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/housewatchinc.com_access_log /var/log/virtualmin/housewatchinc.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/idle-a-while-motel.com_access_log /var/log/virtualmin/idle-a-while-motel.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/hotelriovista.com_access_log /var/log/virtualmin/hotelriovista.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/freestoneinn.com_access_log /var/log/virtualmin/freestoneinn.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/3fingeredjacks.com_access_log /var/log/virtualmin/3fingeredjacks.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/johnstraley.com_access_log /var/log/virtualmin/johnstraley.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/karrosmith.com_access_log /var/log/virtualmin/karrosmith.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/klbcommunityconsulting.com_access_log /var/log/virtualmin/klbcommunityconsulting.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/lanthornphotography.com_access_log /var/log/virtualmin/lanthornphotography.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowtrails.com_access_log /var/log/virtualmin/methowtrails.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/kensletten.com_access_log /var/log/virtualmin/kensletten.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/kristindevin.com_access_log /var/log/virtualmin/kristindevin.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/laurelhurstfancompany.com_access_log /var/log/virtualmin/laurelhurstfancompany.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/local98856.com_access_log /var/log/virtualmin/local98856.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/lostriverwinery.com_access_log /var/log/virtualmin/lostriverwinery.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mcphailberries.com_access_log /var/log/virtualmin/mcphailberries.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methow-lands.com_access_log /var/log/virtualmin/methow-lands.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowbluesky.com_access_log /var/log/virtualmin/methowbluesky.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowtroutfitters.com_access_log /var/log/virtualmin/methowtroutfitters.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/methowvalley.com_access_log /var/log/virtualmin/methowvalley.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowvalleyproperties.com_access_log /var/log/virtualmin/methowvalleyproperties.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowview.com_access_log /var/log/virtualmin/methowview.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/methowwatershed.com_access_log /var/log/virtualmin/methowwatershed.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mistyfjordseafood.com_access_log /var/log/virtualmin/mistyfjordseafood.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mvkillerwhales.com_access_log /var/log/virtualmin/mvkillerwhales.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mvnordic.com_access_log /var/log/virtualmin/mvnordic.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mydogdont.com_access_log /var/log/virtualmin/mydogdont.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/myecofarmer.com_access_log /var/log/virtualmin/myecofarmer.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/tackmansurveying.com_access_log /var/log/virtualmin/tackmansurveying.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/themazamastore.com_access_log /var/log/virtualmin/themazamastore.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/townoftwisp.com_access_log /var/log/virtualmin/townoftwisp.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/townofwinthrop.com_access_log /var/log/virtualmin/townofwinthrop.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/goatwallview.com_access_log /var/log/virtualmin/goatwallview.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/bearcreekequestrian.com_access_log /var/log/virtualmin/bearcreekequestrian.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/bearfightcenter.com_access_log /var/log/virtualmin/bearfightcenter.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/chewuchinn.com_access_log /var/log/virtualmin/chewuchinn.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/confluencegallery.com_access_log /var/log/virtualmin/confluencegallery.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/fassencr.com_access_log /var/log/virtualmin/fassencr.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/fishandfloat.com_access_log /var/log/virtualmin/fishandfloat.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/hoonahnet.com_access_log /var/log/virtualmin/hoonahnet.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mazamacountryinn.com_access_log /var/log/virtualmin/mazamacountryinn.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mazama.org_access_log /var/log/virtualmin/mazama.org_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mazamareservations.com_access_log /var/log/virtualmin/mazamareservations.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/imaginethemethow.org_access_log /var/log/virtualmin/imaginethemethow.org_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/mercplayhouse.org_access_log /var/log/virtualmin/mercplayhouse.org_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowrivercabins.com_access_log /var/log/virtualmin/methowrivercabins.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowsalmon.org_access_log /var/log/virtualmin/methowsalmon.org_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowvalleyappraisal.com_access_log /var/log/virtualmin/methowvalleyappraisal.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowrecycles.org_access_log /var/log/virtualmin/methowrecycles.org_error_log Weekly /usr/sbin/apachectl graceful /var/log/virtualmin/tunesberry.com_access_log /var/log/virtualmin/tunesberry.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/mwheel.com_access_log /var/log/virtualmin/mwheel.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/okanoganelectriccoop.com_access_log /var/log/virtualmin/okanoganelectriccoop.com_error_log Weekly /usr/sbin/apachectl graceful /var/log/virtualmin/remaxvalleylife.com_access_log /var/log/virtualmin/remaxvalleylife.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/townofwinthrop.org_access_log /var/log/virtualmin/townofwinthrop.org_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/pine-forest.org_access_log /var/log/virtualmin/pine-forest.org_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/twisptowncenter.org_access_log /var/log/virtualmin/twisptowncenter.org_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/ultratune.net_access_log /var/log/virtualmin/ultratune.net_error_log Monthly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowmusicfestival.org_access_log /var/log/virtualmin/methowmusicfestival.org_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowvalleypsfa.org_access_log /var/log/virtualmin/methowvalleypsfa.org_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/methowvalleytheater.org_access_log /var/log/virtualmin/methowvalleytheater.org_error_log Weekly /usr/sbin/apachectl graceful /var/log/virtualmin/wiki.methownet.com_access_log /var/log/virtualmin/wiki.methownet.com_error_log Weekly /usr/sbin/apachectl graceful /var/log/virtualmin/lwmusic.com_access_log /var/log/virtualmin/lwmusic.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/forum.methownet.com_access_log /var/log/virtualmin/forum.methownet.com_error_log Weekly /usr/sbin/apachectl graceful /var/log/virtualmin/mvsta.com_access_log /var/log/virtualmin/mvsta.com_error_log Weekly if [ -f /var/run/apache2.pid ]; then /etc/init.d/apache2 restart > /dev/null fi /var/log/virtualmin/hwy20washworks.com_access_log /var/log/virtualmin/hwy20washworks.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/thelambranch.com_access_log /var/log/virtualmin/thelambranch.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/twisppda.com_access_log /var/log/virtualmin/twisppda.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/twisppda.org_access_log /var/log/virtualmin/twisppda.org_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/greenlotusmassage.com_access_log /var/log/virtualmin/greenlotusmassage.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/farmersstatebankwa.com_access_log /var/log/virtualmin/farmersstatebankwa.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/methowengineering.com_access_log /var/log/virtualmin/methowengineering.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/fksdlaw.com_access_log /var/log/virtualmin/fksdlaw.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/twispriverpottery.com_access_log /var/log/virtualmin/twispriverpottery.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/mazamaranchhouse.com_access_log /var/log/virtualmin/mazamaranchhouse.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/mazamajuice.com_access_log /var/log/virtualmin/mazamajuice.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/rosslakeresort.com_access_log /var/log/virtualmin/rosslakeresort.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/heathbeef.com_access_log /var/log/virtualmin/heathbeef.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/hiltonconstruction.com_access_log /var/log/virtualmin/hiltonconstruction.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/rendezvoushuts.com_access_log /var/log/virtualmin/rendezvoushuts.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/methowvalleyrodeo.com_access_log /var/log/virtualmin/methowvalleyrodeo.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/gloverstreetmarket.com_access_log /var/log/virtualmin/gloverstreetmarket.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/recyclingroundup.com_access_log /var/log/virtualmin/recyclingroundup.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/canyonparkorchard.com_access_log /var/log/virtualmin/canyonparkorchard.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/bearfightinstitute.com_access_log /var/log/virtualmin/bearfightinstitute.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/radioroot.com_access_log /var/log/virtualmin/radioroot.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/ncwaudubon.org_access_log /var/log/virtualmin/ncwaudubon.org_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/methowcider.com_access_log /var/log/virtualmin/methowcider.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/thomsonscustommeats.com_access_log /var/log/virtualmin/thomsonscustommeats.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/theretropony.com_access_log /var/log/virtualmin/theretropony.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/texascreekproducts.com_access_log /var/log/virtualmin/texascreekproducts.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/aeromethow.org_access_log /var/log/virtualmin/aeromethow.org_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/bbexcavatinginc.com_access_log /var/log/virtualmin/bbexcavatinginc.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/englishbutlerpropertymanagement.com_access_log /var/log/virtualmin/englishbutlerpropertymanagement.com_error_log Weekly /usr/sbin/apache2ctl graceful /var/log/virtualmin/twispriversuites.com_access_log /var/log/virtualmin/twispriversuites.com_error_log Weekly /usr/sbin/apache2ctl graceful

Status: 
Active

Comments

One other user reported an issue like this as well - it turned out that the cause was too many Apache restarts in rapid succession. It seems that the Apache init script sometimes exits before the webserver has fully shut down, which causes it to fail on startup because port 80 is already in use :-(

The work-around is to edit the postrotate scripts in /etc/logrotate.conf and add the line sleep 5 at the end of each one. Let us know how that goes ..

Maybe, instead of a sleep 5, it might be an idea to wait for the Apache PID file to disappear and then wait maybe an additional second? I think if Apache is coded "nicely", deleting the PID file should be the last thing it does after having freed all its resources.

That would be good too .. however, it would be harder to script than a simple sleep.

Yep that's sure true. Though a sleep 5 would assume that 5 seconds is actually sufficient. :) Which it probably is, while still, waiting for the file to disappear should be more "well-defined".

Thanks. I will try this and let you know. Jeff

This happens to us as well -- 5:30pm every Sunday. Trying the sleep 5 addition at the end of the script at /etc/logrotate.conf

Anyone else find any other ideas?

sheldondesouza's picture
Submitted by sheldondesouza on Thu, 01/24/2019 - 11:35

Hi i am having the same issue since October 2018 till now . When ever there is an update my apache turns off and then i get of Error 511 on the website. i have to login to virtualmin and start the apache server. Does any body have a solution. i am running Virtualmin version 6.05

Same problem here. My last sunday mornings have been spent going through log files.

What does

"The work-around is to edit the postrotate scripts in /etc/logrotate.conf and add the line sleep 5 at the end of each one."

mean exactly? Should I add sleep 5 at the end of the config file or inside each

/var/log/wtmp {
    missingok
    monthly
    create 0664 root utmp
    rotate 1
}

You should add it before each endscript line.

I don't have any "endscript" line in these files.

IIRC this was an issue in an earlier virt version...why not do NOT do the restart after each individual domain and only restart apache at the end of the entire process of rotations? Is it really necessary to restart apache for log rotations?

btw i can report i had this happen on my 16.04LTS box this morning...my 18.04LTS box did NOT have this problem.

I don't know if this is the best way to do this, but it worked for me on Ubuntu 16.04:

I added 'wait 10 &&':

root@www3:~# vim /etc/logrotate.d/apache2
/var/log/apache2/*.log {
        daily
        missingok
        rotate 14
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if /etc/init.d/apache2 status > /dev/null ; then \
                    wait 10 && /etc/init.d/apache2 reload > /dev/null; \
                fi;
        endscript
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
}

oh so the file to modify is /etc/logrotate.d/apache2 and not /etc/logrotate.conf. I'll try that