This question is for running perl on windows 2012 server.
So I have a folder called Commands_To_Run and under there are 100 batch files e.g.
Commands_To_Run
- run_1.bat
- run_2.bat
- run_3.bat
...
- run_100.bat
Each of these run*.bat files take about 30 mins to complete. If I run these batch files serially using a FOR loop then it takes me 100 * 30 min to run. (Too long!)
What I want to is write a perl script that will execute 10 batch files at a time. Once any one of the batch files complete the next batch file would get executed.
For example I would like to execute run1.bat through run10.bat. Let's say run7.bat finishes then I want to run next run11.bat and so on. So there are 10 files running at any given time.
I thought about using this perl script to run batch file but this will run all 100 at the same time and it will kill my windows CPU & processing.
for ($x=0; $x < scalar(@files); $x++ ) {
$file=@files[$x];
chomp $file;
$cmd="start $file ";
print "Runnung Command is: $cmd\n";
system($cmd);
}
I looked at the suggestion given but there is no working example of how to use use Forks::Super