2

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).

1
  • pcntl_fork should work Commented Jul 8, 2012 at 8:08

3 Answers 3

4

You put them in background.

for ($i=1; $i<=137; $i++) {
    exec("/usr/bin/php /files/file$i.php > /dev/null 2>&1 &");
}
Sign up to request clarification or add additional context in comments.

1 Comment

I know this is old but I didn't want to create the same question... My question is, will I be able to run multiple instances of one script by passing in different parameters with this method?
1

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 &

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.