RickJames
asked on
Sysinternals ProcDump Script
Hello Experts,
I am having difficulty scripting ProcDump to actively monitor/attach to a process and when the process terminates, crashes, or hangs to take a Full Dump and finally continue to listen in a loop for the next instance of the processes' start for ProcDump to attach/monitor etc...
I would like for the dumps of the process (a service) to be limited to 4 dumps and overwrite the oldest dump file at each dump exceeding the 4th dump.
Below are the command line switches I am using
cd D:\ProcDump\
START ""/min "procdump" -e -h -t -ma "SomeProcess.exe" -accepteula SomeProcessDump.dmp"
http://technet.microsoft.c om/en-us/s ysinternal s/dd996900 .aspx
Thank you,
I am having difficulty scripting ProcDump to actively monitor/attach to a process and when the process terminates, crashes, or hangs to take a Full Dump and finally continue to listen in a loop for the next instance of the processes' start for ProcDump to attach/monitor etc...
I would like for the dumps of the process (a service) to be limited to 4 dumps and overwrite the oldest dump file at each dump exceeding the 4th dump.
Below are the command line switches I am using
cd D:\ProcDump\
START ""/min "procdump" -e -h -t -ma "SomeProcess.exe" -accepteula SomeProcessDump.dmp"
http://technet.microsoft.c
Thank you,
ASKER
Someone will have an easy 500 points soon... (i think anyway if piping in a command is easy to do or if I don't figure it out first :) )
From the link below it appears in addition to piping in Ctrl-C that I will have to create another bat script to call the bat script above with the CMD /c option to prevent the above bat script from also exiting when the piped Ctrl-C is sent at each loop.
http://ss64.com/nt/cmd.html
If one batch file CALLs another batch file CTRL-C will exit both batch scripts.
If CMD /c is used to call one batch file from another then CTRL-C will cause only one of the batch scripts to terminate.
From the link below it appears in addition to piping in Ctrl-C that I will have to create another bat script to call the bat script above with the CMD /c option to prevent the above bat script from also exiting when the piped Ctrl-C is sent at each loop.
http://ss64.com/nt/cmd.html
If one batch file CALLs another batch file CTRL-C will exit both batch scripts.
If CMD /c is used to call one batch file from another then CTRL-C will cause only one of the batch scripts to terminate.
ASKER
Adding below seems a valid option. Now I will test & verify.
:holding
ping localhost -n %wait% > NUL 2>&1
FIND /I /V "SomeProcess.exe"
IF NOT ERRORLEVEL 1 GOTO :wait
IF ERRORLEVEL 1 goto :proceed
:wait
ping localhost -n %wait% > NUL 2>&1
FIND /I /V "SomeProcess.exe"
IF NOT ERRORLEVEL 1 GOTO :holding
IF ERRORLEVEL 1 goto :proceed
:proceed
if %count% GTR %keep% del "%oldest%"
goto :_loop
:holding
ping localhost -n %wait% > NUL 2>&1
FIND /I /V "SomeProcess.exe"
IF NOT ERRORLEVEL 1 GOTO :wait
IF ERRORLEVEL 1 goto :proceed
:wait
ping localhost -n %wait% > NUL 2>&1
FIND /I /V "SomeProcess.exe"
IF NOT ERRORLEVEL 1 GOTO :holding
IF ERRORLEVEL 1 goto :proceed
:proceed
if %count% GTR %keep% del "%oldest%"
goto :_loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No one else helped and it was an acceptable solution to what I had originally requested
Rick,
Thanks for sharing your findings.
Cheers,
Rene
Thanks for sharing your findings.
Cheers,
Rene
ASKER
Thanks,
@echo off
setlocal
set pd=D:\procdump.exe
set dest=D:\procdump\SomeProce
set wait=60
set keep=4
:_loop
set shortdatetime=%date:~10,4%
cd D:\ProcDump\
START ""/min "procdump" -e -h -ma -n 20 "SomeProcessDump*.dmp" -accepteula %dest%\SomeProcessDump.dmp
ping localhost -n %wait% > NUL 2>&1
ren "%dest%\SomeProcessService
set count=0
for /f "tokens=*" %%G in ('dir "%dest%\*SomeProcessServic
set oldest=%dest%\%%G
set /a count+=1
)
if %count% GTR %keep% del "%oldest%"
goto :_loop
if %count% GTR %keep% del "%oldest%"
goto :_loop