Pergunta

I have this sample code called main.php:

<?php
shell_exec('C:\wamp\bin\php\php5.4.3\php.exe a.php');
shell_exec('C:\wamp\bin\php\php5.4.3\php.exe b.php');
?>

when execute this script after executing first shell_exec it staying until finishing first shell_exec and then run second.

but I want that script dont stay for finishing first shell_exec and its output and runs second.

now how can I do this?

I have several scripts and I need to run them Simultaneously by a main script and control them by it. but I dont know that how to run my scripts Simultaneously from inside of this main script?

update1: I cant run a.php and b.php by cron jobs because their finishing time is unknown. maybe a.php finished after 1 hour or 10 minutes and b.php as same as a.php too.

update2: I founded a solution in this page:

Is there a way to use shell_exec without waiting for the command to complete?

Foi útil?

Solução

If i understand you wish to run a background process on a Windows box.Suggest try this...

<?php
    shell_exec('start /b C:\wamp\bin\php\php5.4.3\php.exe a.php');
    shell_exec('start /b C:\wamp\bin\php\php5.4.3\php.exe b.php');
?>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top