Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running multiple commands simultaneously

Tags:

batch-file

cmd

I have a script that will run open multiple cmd windows and run different php commands in each window. Unfortunately, my current code waits for the first set of PHP commands to finish before the second set of PHP commands starts, defeating the purpose of opening multiple windows.

Is it possible to run all sets of PHP commands in separate cmd windows simultaneously?

My current code:

start
cd c:\users\administrator\desktop\chps\chp1
php checker.php
start
cd c:\users\administrator\desktop\chps\chp2
php checker.php
start
cd c:\users\administrator\desktop\chps\chp3
php checker.php
start
cd c:\users\administrator\desktop\chps\chp4
php checker.php
start
cd c:\users\administrator\desktop\chps\chp5
php checker.php
start
cd c:\users\administrator\desktop\chps\chp6
php checker.php
start
cd c:\users\administrator\desktop\chps\chp7
php checker.php
start
cd c:\users\administrator\desktop\chps\chp8
php checker.php
start
cd c:\users\administrator\desktop\chps\chp9
php checker.php
start
cd c:\users\administrator\desktop\chps\chp10
like image 371
Mohammed naji Avatar asked Dec 20 '22 04:12

Mohammed naji


1 Answers

start "" /d "c:\users\administrator\desktop\chps\chp1" php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp2" php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp3" php checker.php

In above code snippet:

  • start command starts a separate Command Prompt window to run a specified program or command.
  • /d switch specifies the startup directory for new Command Prompt.

You could ensure and force creating a new instance of the command interpreter (Cmd.exe) as follows:

start "" /d "c:\users\administrator\desktop\chps\chp1" cmd /C php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp2" cmd /C php checker.php
start "" /d "c:\users\administrator\desktop\chps\chp3" cmd /C php checker.php
like image 117
JosefZ Avatar answered Feb 08 '23 13:02

JosefZ