parallel processing - PowerShell: How to write to a file from multiple jobs? -
okay, here's pseudo-code of i'm trying do:
function dothings() { $onejob = { ### things... # want capture stdout *and* stderr of these 3 commands a_command >> "logfile.log" 2>&1 b_command >> "logfile.log" 2>&1 c_command >> "logfile.log" 2>&1 } $params = @{ } ($i=1; $i -lt 100; $i++) { ### manipulate $params here start-job $onejob -argumentlist $params } }
however, naively running above resulted in several jobs ending errors, because apparently "logfile.log" being opened job running @ same time.
so, how ensure jobs not step on each other's shoes when writing "logfile.log" file?
Comments
Post a Comment