0

I have a PHP script that executes shell commands... I'm running into an issue where the PHP script is on hold until it receives output from the shell command. If the shell command takes 5 minutes, the PHP script does too. This is OK, but what I'm also runing into is that while the page is stalled, it also stalls out the entire site until the shell script is finished. I'm trying to understand why this is happening...

I've created a hello.php and put a simple echo 'hello world'; in it and was able to successfully run it while the PHP script was waiting for the shell command to finish. This tells me that when the site stalls, it has to be something related to the PHP files being in use, so it won't serve additional page requests.

Any thoughts?

1
  • What is the webserver and how are you running the PHP? mod_php? fastcgi?
    – DerfK
    Aug 15, 2011 at 12:41

1 Answer 1

1

Nearly all process execution functions in PHP (e.g. exec, backtick operator, shell_exec) wait for the called program to finish. That's the way it is.

If you want to do other things in your PHP script while the called program is running, either background it or use PHP's process control functions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .