From 922baf932eb9cf1f83c940b1e6697721d08c720d Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Thu, 25 Jul 2019 22:27:45 -0700 Subject: [PATCH] Reduce truncation of information in the runningProcesses*.txt files (#12398) - widen lines in process dump files - increase process dump frequency to once every 2 minutes (from 5 minutes) - simplify process dump filenames - no need to keep files from previous ./build.ps1 invocations around - by definition, job isn't hung if it can move to next build step - save previous process dump files - should help if cancellation kills processes before final process dump runs nits: - move from deprecated `Get-WmiObject` to `Get-CimInstance` - trim trailing whitespace --- eng/scripts/dump_process.ps1 | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/eng/scripts/dump_process.ps1 b/eng/scripts/dump_process.ps1 index 3c35ea29ee..f3ad56fcf7 100644 --- a/eng/scripts/dump_process.ps1 +++ b/eng/scripts/dump_process.ps1 @@ -1,9 +1,17 @@ Set-Location $args[0] -$timestamp = $(get-date -f MM-dd-HH-mm) - while ($true) { - Get-Process > artifacts/log/runningProcesses.$timestamp.txt - Get-WmiObject Win32_Process | select name, processid, commandline > artifacts/log/runningProcessesCommandLine.$timestamp.txt - Start-Sleep -Seconds 300 -} \ No newline at end of file + $local:file = "artifacts/log/runningProcesses.txt" + if (Test-Path $file) {Move-Item -Force $file "$file.bak"} + + $local:temp = Get-Process |Out-String -Width 300 + $temp.Split([Environment]::NewLine).TrimEnd() |? Length -gt 0 |Out-File -Width 300 $file + + $file = "artifacts/log/runningProcessesCommandLine.txt" + if (Test-Path $file) {Move-Item -Force $file "$file.bak"} + + $temp = Get-CimInstance Win32_Process |Format-Table -AutoSize Name, ProcessId, CommandLine |Out-String -Width 800 + $temp.Split([Environment]::NewLine).TrimEnd() |? Length -gt 0 |Out-File -Width 800 $file + + Start-Sleep -Seconds 120 +}