I am running a (detached) PHP script from the command line, which itself uses shell_exec() to launch other PHP scripts. I had expected that each of these scripts would be launched almost immediately, but instead it appears to be waiting for one to complete before the code continues to the next one.
This is essentially what I'm running. How can I allow my script to continue through the foreach loop without waiting for each shell_exec() to terminate?
foreach ($rows as $row) { $output = shell_exec("php path/to/file.php $estab_code") ; } Really, my expected outcome here is that each shell_exec() should trigger a new one-off Heroku dyno to be launched, with all of them running concurrently. However, that doesn't appear to be happening: the executed script seems to be running from the original dyno.
Any ideas?
1 Answers
Answers 1
shell_exec waits for the command to return something. In order to make that something happen immediately and be empty, you could tack the following onto each command:
> /dev/null 2>/dev/null & Something like this:
foreach ($rows as $row) { $output = shell_exec("php path/to/file.php $estab_code > /dev/null 2>/dev/null &"); }
0 comments:
Post a Comment