exec() in multiple threads?

Discussion in 'PHP' started by paume, Nov 7, 2008.

  1. #1
    Hi,

    I want my php script (a.php) to call another script (b.php) and run it in "background" mode.

    This is what I use in a.php:

    exec ("/usr/bin/php b.php >/dev/null &");

    And this is what I place in b.php (among other commands):

    sleep(30)

    When I run a.php, it calls b.php, which makes the script wait for 30 seconds.

    Now imagine that, during those 30 seconds, the script a.php in the same http session calls the exec above for a second time.

    It appears that the second call is ignored, as if the first "process" needs to be completed before b.php can be invoked again.

    Is it possible to call b.php multiple times in multiple independent threads, so each of them can have a different outcome?

    Thanks
     
    paume, Nov 7, 2008 IP