Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem on a page "php scripts continues to become defunct", and appears to be the page1.php script. Parent process is terminated while child is not being terminate. I am using shell_exec function to run linux commands.
shell_exec("killall -9 httpd");
shell_exec("killall -9 mysqld");
shell_exec("service httpd restart");
shell_exec("service mysqld restart");

is this code right? 2-3K people use this file at a time. Please guide me?

share|improve this question

For killall and service to work the php-script need to execute as root, or some other user with appropriate permissions. Is this a standard alone shell script or a web page?

A kill -9 should be avoided because the application may lose data, for example, mysql may not have time to save everything to permanent storage before the process is killed. Kill -9 is a convenient command for these special cases but I do not recommend to use this as a part of a script.

share|improve this answer
may you suggest any other efficient way to kill child processes. we have 60k daily users and we are in trouble. – Granadian Jul 19 '11 at 10:28
Can you clarify your question, I'm not completely sure what you want to do. – nsg Jul 19 '11 at 10:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.