Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I simultaneously run dozens of PHP scripts in the background from XAMPP's command line interface?

Someone suggested a batch file, but when I tried executing this:

start php 1.php
start php 2.php
start php 3.php

It only opened a command prompt window; I closed that window, then two more command prompt windows opened up executing 2.php and 3.php.

I want to run as many scripts as I want all simultaneously and all in the background. What is the best way to accomplish this, and how can it be done?

EDIT Here is how to accomplish this:

1) Download PowerShell 2 (or the compatible version with your Windows version) from here:

2) Install it and restart your computer.

3) Make a new file "example.ps1" and save it to a directory of your choice (e.g. c:\examples\example.ps1). Put this code in that file:

start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\1.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\2.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\3.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\4.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\5.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\6.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\7.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\8.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\9.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\10.php}
start-job {.\c:\xampp\php\php C:\xampp\htdocs\phpfiles\11.php}

4) Click on "Start" -> "Run" and type in "powershell" (without quotes).

5) After PowerShell initiates, type in the following and press enter:

Set-ExecutionPolicy RemoteSigned

Then press "y" to set the changes.

6) Now type in (make sure to enter in the full file path):


7) To see your jobs simply type in:


To stop a job use this command:

stop-job JobName
share|improve this question
up vote 1 down vote accepted

Add some options after your start:

start /min cmd /c php -f 1.php

This will suppress the additional command prompts.

share|improve this answer
Thanks, but this only minimizes the 3 command prompt windows. Is there a way to run multiple scripts through CLI entirely in the background (in one window only)? – Pamela Aug 30 '12 at 15:48
For that, you will need the POSIX capabilities of PowerShell. Look at this article:!7143DA6E51A2628D!130.entry – Mike Mackintosh Aug 30 '12 at 15:55
Thanks! That article is a bit outdated as PowerShell now integrates background jobs. I've updated my question with the full instructions on how to accomplish this. – Pamela Aug 30 '12 at 19:01
Awesome job!!!! – Mike Mackintosh Aug 30 '12 at 19:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.