locked
Log server running processes for 1 hour using tasklist command RRS feed

  • Question

  • Hello,

    I have been troubleshooting an intermittent application crash issue happened late at night at a certain time. I  and would like to find out what server processes running when the application crashes.

    I suspect the problem may relate to some process that interferes with the application at the application crash time. I set up a scheduled task to log all running process name and which userID running it.

    I used to tasklist command that checks the server every 5 seconds for a duration of 1 hour. I also filter out only process name and userID field.

    Below is contents of taskmonitor.cmd:

    for /f "delims=/ tokens=1-3" %%a in ("%DATE:~4%") do (

       set logname=F:\temp\tasklog-%%c-%%b-%%a
       Echo Job started on %%c-%%b-%%a  > %logname%.txt

    )


    for /l %%x in (1, 1, 720) do (
       echo %time% >> %logname%.txt
       for /f "tokens=1,8 delims=," %%F in ('tasklist  /nh /v /fo csv') do @echo %%~F  %%~G >> %logname%.txt
       timeout /t 4
    )

    Friday, March 11, 2016 10:11 PM

Answers

All replies

  • This tech note was resolved
    • Marked as answer by Elaine Jing Tuesday, March 15, 2016 7:21 AM
    Friday, March 11, 2016 10:17 PM
  • Hi kevin,

    Thanks for the post. Glad to know your issue has been fixed, we'd appreciate if you could share the solution with us.

    Best Regards,

    Elaine


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, March 15, 2016 7:22 AM