Reputation: 627
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
Upvotes: 0
Views: 1085
Reputation: 627
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')
Upvotes: 1
Reputation: 1272
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.
Upvotes: 0
Reputation: 24723
You put a &
between scripts
php /var/www/script1.php & php /var/www/script2.php ........
Upvotes: 0