homepage Welcome to WebmasterWorld Guest from 54.197.94.241
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
shell script to restart apache when no. of processes keeps growing
Can I have your help?
Jo555




msg:3272244
 5:36 am on Mar 6, 2007 (gmt 0)

I need a shell script to kill apache and restart it, in case the number of processes keeps growing. The logic is like the below, but I don't know how to get the number and neither the syntax. Could somebody kindly help?

if no_of_processes (ps ax ¦ grep httpd) > 200
then
killall httpd
apachectl start

 

bcc1234




msg:3272255
 6:02 am on Mar 6, 2007 (gmt 0)

PROC_COUNT=`ps aux ¦ grep <apache process name> ¦ wc -l`
if [ "${RPOC_COUNT}" -gt "200" ]
then
whatever here
fi

But you really have bigger issues if the number of processes keeps growing. A script like that is a bad solution.

Jo555




msg:3272464
 11:38 am on Mar 6, 2007 (gmt 0)

Thank you so much for the script, bcc1234. It's going to be my first shell script.

Yes the real issue is bigger, but I have no clue why the number of processes keep growing and can't be killed automatically by the system.
When that happens, there are accordingly growing number of records like those below in the httpd log file.

[Mon Mar 05 16:08:15 2007] [warn] child process 24829 still did not exit, sending a SIGTERM
and
[Mon Mar 05 16:08:21 2007] [error] child process 24829 still did not exit, sending a SIGKILL

I think it has something to do with mysql, because at the early stage before the server is brought down, dynamic pages using mysql slow down while static pages of plain text still respond normally.

At the moment I simply don't know what I can do to get closer to finding out what is the origin of the issue. Can anybody give me some advices or suggestions or any comments?

nalin




msg:3280701
 3:41 pm on Mar 13, 2007 (gmt 0)

In lieu of the shell script you could try something like "monit".

As far as having a large number of open threads - you might want to check your http.conf and make sure keepalive is disabled or has a very low timeout.

Keepalive makes a thread that serves up a page stay open (to respond to other requests for more pages or css or js or images). Generally you will get MUCH improved performance out of apache if you use it for dynamic content only (which makes keepalive useless because apache will be generating only a single request per page) and serve up js, css, images, and other static stuff via something more lightweight (I use squid in reverse proxy mode).

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved