Aug 292007
 

I use apache to serve a few sites from the fire­wall box in the base­ment and for some reas­on it kept dying on a reg­u­lar basis. This star­ted fairly recently, some time after I set up sep­ar­ate access log files for each of the sites.

The error logs showed entries like 

[Sun Jun 10 06:28:03 2007] [warn] child process 16516 still 
did not exit, sending a SIGTERM

which seemed bizarre and wer­en’t being spawned by any­thing obvi­ous in the access logs. I even­tu­ally remembered that I had set up log rota­tion for each of the vir­tu­al hosts, and went search­ing through the error logs to see if it was related. Sure enough, the shut-down was hap­pen­ing at the same time, and so the log rota­tion was likely to be related to the cause. But what could be the real cause? Surely not just rotat­ing logs…

A bit of pok­ing around the web found that oth­er people have had this prob­lem. I went down a bunch of dead ends (vir­tu­al hosts? apache2ctl restart vs apache2ctl start?) and even­tu­ally just turned error report­ing up to the max­im­um. The next week, after the serv­er went dead again, I found the fol­low­ing email in my sysad­min inbox.

/etc/cron.daily/logrotate:
(98)Address already in use: make_sock: could not bind to 
address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
error: error running shared postrotate script for 
/var/log/apache2/*.log
run-parts: /etc/cron.daily/logrotate exited with return 
code 1

Hunt­ing around more on the web, I found a recom­mend­a­tion to expli­citly set the TMPDIR envir­on­ment vari­able before run­ning logrotate. Apache has now been up for a few weeks without fall­ing over, prob­lem solved! I’m still not sure why this only star­ted to hap­pen after set­ting up sep­ar­ate log files for the sep­ar­ate vir­tu­al hosts, or even if that was more than a prox­im­ate coincidence.

  One Response to “Apache and Logrotate”

  1. Found this post­ing http://www.heckofaworld.com/?p=11. It’s an inter­est­ing dis­cus­sion of the prob­lem with a couple of solu­tions. Mind you, set­ting TMPDIR expli­citly solved the prob­lem for me; Apache has­n’t fallen over since.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

/* ]]> */