bpmccain
bpmccain

Reputation: 600

Executing multiple simultaneous php scripts from CLI

I have 55 php files that I would like to run simultaneously from the command line. Right now, I am running them in multiple CLI windows using the code:

php Script1.php

I would like to be able to call one single php file that would execute all 55 php files simultaneously. I have been reading about how to make the command line not wait for the output, but I can't seem to make it work.

This thread: How to run multiple PHP scripts from CLI

suggests putting an & at the end of the command to run the command in the background, but using the xampp CLI this doesn't seem to do anything.

Any ideas greatly appreciated.

Brian

Upvotes: 4

Views: 5910

Answers (3)

cweiske
cweiske

Reputation: 31078

Linux

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: 2

recluze
recluze

Reputation: 1915

You could use the php forking mechanism. Read about it here: http://php.net/manual/en/function.pcntl-fork.php

Upvotes: 1

Tudor Constantin
Tudor Constantin

Reputation: 26861

By mentioning XAMPP, I assume you are on windows. I think what you need is the start command. You probably need start php Script1.php. For more info, do a

start /?|more

Upvotes: 3

Related Questions