Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
What is the webserver and how are you running the PHP? mod_php? fastcgi? –  DerfK Aug 15 '11 at 12:41

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

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.