need help: shell script to restart apache when no. of processes keeps growing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help: shell script to restart apache when no. of processes keeps growing
# 8  
Old 03-06-2007
Quote:
Originally Posted by jacoden
killall httpd -------------> I assumed killing all the httpd processes...

killall ?????????????????????????

That's the first thing that comes to your mind?

Ever considered trying to stop something in a decent way instead of using kill as first option?
# 9  
Old 03-06-2007
Quote:
Originally Posted by sb008
killall ?????????????????????????

That's the first thing that comes to your mind?

Ever considered trying to stop something in a decent way instead of using kill as first option?
Thanks sb008, do you any suggestion?
The problem is that when the number of processes grows abnormally, finally not only apache but also the whole server can be brought down.
By now I haven't found out the cause, but just thought that at lease I can save the server from being down by using kill or killall. I really have no better idea at the moment.
# 10  
Old 03-06-2007
Have you tried setting MaxClients within your Apache configuration as I indicated above?

You should really be concentrating your efforts on trying to find the cause of the issue, rather than circumventing it with a shonky workaround.

Cheers
ZB
# 11  
Old 03-06-2007
Quote:
Originally Posted by sb008
killall ?????????????????????????

That's the first thing that comes to your mind?

Ever considered trying to stop something in a decent way instead of using kill as first option?
sb008,

I know that kill command is not the best bet to stop a process...but,I have observed in many such kind of cases that kill 'is a better choice' as stopping the process using the 'decent way' might end up in many 'zombie' processes...
# 12  
Old 03-07-2007
Quote:
Originally Posted by jacoden
sb008,

I know that kill command is not the best bet to stop a process...but,I have observed in many such kind of cases that kill 'is a better choice' as stopping the process using the 'decent way' might end up in many 'zombie' processes...
Why is that? Smilie

Then possibly that should be a bug with respect to the parent which refuses to reap the exit status and process statistics of the child.
# 13  
Old 03-07-2007
Quote:
Originally Posted by zazzybob
Have you tried setting MaxClients within your Apache configuration as I indicated above?

You should really be concentrating your efforts on trying to find the cause of the issue, rather than circumventing it with a shonky workaround.

Cheers
ZB
Thanks ZB, you are absolutely right.
I tried to change MaxClients, but because the number of processes grows almost infinitely, I know something must be wrong which is causing the issue.
Sadly I only know it should has something to do with mysql, but no idea how to get closer.
# 14  
Old 03-07-2007
Quote:
Originally Posted by matrixmadhan
Why is that? Smilie

Then possibly that should be a bug with respect to the parent which refuses to reap the exit status and process statistics of the child.
Or never receives the dead of child signal.

This is most likely to obtain for orocess which are started, to put it simple, with the nohup option. When the initional "httpd" daemon dies, parenthood for all child "httpd" daemons is passed over to the "init" process.

This is bug sensitive.

Therefore a kill, as shown, will more likely cause zombie processes since the order in which the "httpd" daemons are killed is random meaning the parent "httpd" is almost for sure killed before at least some of the "httpd" child processes.

Furthermore a "kill -9" might result in a not proper cleaning of the resources which are used by the process. When killing enough processes like that, at some stage the system will end up with an internal chaos which can cause all kind of unexpected/unwanted behavior like zombie processes starting to occur.

The "kill -9" is meant for when all other options fail, and surely not as first option.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to restart shell script when cpu is 0.0%?

Hello, My operating system is ubuntu 16.04. I need to kill or restart a shell script when cpu usage of related process is equal to 0.0% for X seconds. Appearing name on top page is vlc While surfing on forums, I found below script but not sure how to edit: Also don't know the function of -gt... (7 Replies)
Discussion started by: baris35
7 Replies

2. Red Hat

Apache service not coming up after restart

When I update the server with new SSL certificates, and restart httpd, I get errors : # service httpd restart Stopping httpd: rm: cannot remove `/usr/local/apache2/bin/httpd/logs/httpd.pid': Not a directory Starting httpd: ... (0 Replies)
Discussion started by: anaigini45
0 Replies

3. Red Hat

Error Restart apache

Hi Im apache service restart Error $ service httpd reload Reloading httpd: service httpd reload Reloading httpd: service httpd start Starting httpd: (98)Address already in use: make_sock: could not bind to address :80 (98)Address already in... (1 Reply)
Discussion started by: mnnn
1 Replies

4. Shell Programming and Scripting

Script to restart apache when running out of memory

Hi, I have a problem with running out of memory in my Ubuntu web server (4GB RAM) because many people try to access my server. I used to restart manually my apache server to clear out the memory & swap. Can anyone tell me how to write bash script that can automatically restart apache when... (2 Replies)
Discussion started by: nica
2 Replies

5. Shell Programming and Scripting

Help scripting to start, check, and restart processes

Here it goes from my unexperienced point of view. I am using CentOS 5.6. I have a Java based server that needs to be running 24/7/365. To begin from the machine the server is on rebooting; I SSH in to a shell, cd to the server dir, screen -S server1, and execute ./exec (listed below) in the screen.... (12 Replies)
Discussion started by: MacG32
12 Replies

6. Shell Programming and Scripting

How to keep process running after apache restart.

I have posted this on the Web subforum but it seems that nobody knows to do this, maybe someone has a solution here. Thank you I have a PHP application that starts a couple of processes on the server...the problem is that if I restart apache those running apps will die. How can I start them... (1 Reply)
Discussion started by: valiadi
1 Replies

7. Web Development

How to keep process running after apache restart.

Hi, I have a PHP application that starts a couple of processes on the server...the problem is that if I restart apache those running apps will die. How can I start them in a way that they are not killed when I restart/stop apache ? $cmdstr = "nohup ".$config."/".$config."... (6 Replies)
Discussion started by: valiadi
6 Replies

8. Shell Programming and Scripting

Restart Logic for a Korn Shell Master Script

Hello All, I was wondering if someone can help me to develop restart logic for a Korn Shell program (a master script) that I am developing. The program is design to invoke a series of child processes (Korn Shell Scripts) whose function is to create a series of load files on a specified mount... (0 Replies)
Discussion started by: jonesdk5
0 Replies

9. Web Development

Can't restart apache. PHP is broken.

I need to restart my apache, but apachectl configtest tells me that Syntax error on line 208 of /etc/httpd/conf/httpd.conf: Cannot load /usr/local/apache/libexec/libphp4.so into server: /usr/local/apache/libexec/libphp4.so: undefined symbol: ap_signal I've tried rebuilding php, I'm not... (2 Replies)
Discussion started by: tatebn
2 Replies

10. Shell Programming and Scripting

suspend/restart a process in shell script

Hi, I have a task that Im stuck on. I have an elementary script named 'myscript' that prints "the script is running" once a second. It runs for 27 seconds. I need to write a 2nd script that starts 'myscript' and takes a parameter '$1' for a number. my 2nd script then needs to pause myscript... (1 Reply)
Discussion started by: daneensign
1 Replies
Login or Register to Ask a Question