I'm using php's shell_exec to call bash files, system programs and Ksh files.
One issue with shell_exec is that if you need the output, your web server will lock up (i.e., no new requests will be served) until the process is finished. A common trick is to set the process to run in the background (> /dev/null 2> /dev/null &), but this of course, discards any output.
I tried switching from apache to nginx thinking that this would solve my problem but the underlying issue appears to be how php's shell_exec blocks i/o. Even with nginx, shell_exec completely blocks any new http requests from completing.
Does anyone know how to make system calls using php without locking up the server, while also capturing the output?
I'm thinking of making a library that manages asynchronous system calls whereby the output can be retrieved later using Ajax.
But I'd prefer not to go that route. Any suggestions?