I wrote a script where I want to break one file into small parts and process all small parts same time to get better performance. I am using for loop inside a job and creating child jobs from there. While executing the script sometimes all small parts are
processing fine. Sometimes 2 of them processing for same source. Any idea why this is happening?
*************************************************************************************************
Script 1: Master.ps1
Start-Job -filepath "sc_8200.ps1"
*************************************************************************************************
Script 2: sc_8200.ps1
$files = Get-ChildItem "\Desktop\sc" -Filter "splitlog*" | Select-Object -Expand fullname
foreach($file in $files)
{
Start-Job -Name $file -filepath "\Desktop\sc\sc_8200_child.ps1" -ArgumentList $file
}
*************************************************************************************************
Note: "splitlog" is name of small files.
*************************************************************************************************
Script 3: sc_8200_child.ps1
param (
[string]$path
)
Function Test()
{
$contents = Get-Content $path
foreach($content in $contents)
{
$temp = $path.SubString(0,$path.Length-4)
$outputfile = $temp+"_O.txt"
Get-ChildItem $content -Recurse -include *.* | Select-Object -Expand fullname >> $outputfile
}
}
Test
*************************************************************************************************