Okay I have 50 php scripts each of which will take 20 days to finish I want to write a PHP script to run these 50 scripts simultaneously I did use exec() function in my script but the problem is it runs first script and wait until it is finished before executing the next script. I want to run all of them in parallel.Is there any way to do that? Thanks
-
see unix.stackexchange.com/questions/169326/…user4962466– user49624662016年04月24日 15:16:24 +00:00Commented Apr 24, 2016 at 15:16
3 Answers 3
Okay thanks I got my answer after a lot of search
Apart from adding a &, you also need to redirect output to somewhere - otherwise your php process waits until the other process finished, because there could be more output:
exec('/path/to/program & > /dev/null 2>&1')
Comments
You put a & between scripts
php /var/www/script1.php & php /var/www/script2.php ........
Comments
if have to use only php, more "php'iish" way to do this is Robo (https://robo.li) it is used with codeception, for example.