Reputation: 65
I have 137 php files i want to run them in one command (in parallel) not by sequence. But the problem is each file is taking 2-5 seconds. So i have tried to make a (.sh) file and put each line as :
/usr/bin/php /files/file1.php
/usr/bin/php /files/file2.php
/usr/bin/php /files/file3.php
It will complete file1 and then run file2 and file3 by sequence. So please what is the php or sh command to run 137 php files all in one click (parallel).
Upvotes: 2
Views: 2452
Reputation: 4062
You can use pcntl lib , that enables threads in php, you can use that and create a php-master file that will call other , and then you can master file from command file
Upvotes: 0
Reputation: 8775
Run the scripts in the background by adding 'nohup' and '&'
nohup /usr/bin/php /files/file1.php &
nohup /usr/bin/php /files/file2.php &
nohup /usr/bin/php /files/file3.php &
Upvotes: 1
Reputation: 160833
You put them in background.
for ($i=1; $i<=137; $i++) {
exec("/usr/bin/php /files/file$i.php > /dev/null 2>&1 &");
}
Upvotes: 4