0

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?

Granadian
  • 25
  • 4

1 Answers1

0

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.

nsg
  • 375
  • 2
  • 10
  • 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
  • 1
    Can you clarify your question, I'm not completely sure what you want to do. – nsg Jul 19 '11 at 10:56