Process monitoring

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Crusty5253
Posts: 2
Joined: 08 Mar 2014 15:49

Process monitoring

#1 Post by Crusty5253 » 08 Mar 2014 15:53

Is there any way to monitor a process "name.exe" and check every couple minutes to see if it's responding? And if not to kill it? I really don't know BATCH that well and need to monitor a game server that keeps crashing.

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Process monitoring

#2 Post by Squashman » 08 Mar 2014 16:28

How are we suppose to know when it is not responding?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Process monitoring

#3 Post by foxidrive » 09 Mar 2014 01:12

tasklist has a filter for not responding.

Crusty5253
Posts: 2
Joined: 08 Mar 2014 15:49

Re: Process monitoring

#4 Post by Crusty5253 » 10 Mar 2014 22:24

Figured there would be a way of pinging a process like you might ping an webserver or IP, so how should I approach this?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Process monitoring

#5 Post by Squashman » 11 Mar 2014 06:32

Crusty5253 wrote:Figured there would be a way of pinging a process like you might ping an webserver or IP, so how should I approach this?


Yes. As Foxidrive already stated look at the TASKLIST STATUS.

Code: Select all

H:\>tasklist /?

TASKLIST [/S system [/U username [/P [password]]]]
         [/M [module] | /SVC | /V] [/FI filter] [/FO format] [/NH]

Description:
    This tool displays a list of currently running processes on
    either a local or remote machine.

Parameter List:
   /S     system           Specifies the remote system to connect to.

   /U     [domain\]user    Specifies the user context under which
                           the command should execute.

   /P     [password]       Specifies the password for the given
                           user context. Prompts for input if omitted.

   /M     [module]         Lists all tasks currently using the given
                           exe/dll name. If the module name is not
                           specified all loaded modules are displayed.

   /SVC                    Displays services hosted in each process.

   /V                      Displays verbose task information.

   /FI    filter           Displays a set of tasks that match a
                           given criteria specified by the filter.

   /FO    format           Specifies the output format.
                           Valid values: "TABLE", "LIST", "CSV".

   /NH                     Specifies that the "Column Header" should
                           not be displayed in the output.
                           Valid only for "TABLE" and "CSV" formats.

   /?                      Displays this help message.

Filters:
    Filter Name     Valid Operators           Valid Value(s)
    -----------     ---------------           --------------------------
    STATUS          eq, ne                    RUNNING |
                                              NOT RESPONDING | UNKNOWN
    IMAGENAME       eq, ne                    Image name
    PID             eq, ne, gt, lt, ge, le    PID value
    SESSION         eq, ne, gt, lt, ge, le    Session number
    SESSIONNAME     eq, ne                    Session name
    CPUTIME         eq, ne, gt, lt, ge, le    CPU time in the format
                                              of hh:mm:ss.
                                              hh - hours,
                                              mm - minutes, ss - seconds
    MEMUSAGE        eq, ne, gt, lt, ge, le    Memory usage in KB
    USERNAME        eq, ne                    User name in [domain\]user
                                              format
    SERVICES        eq, ne                    Service name
    WINDOWTITLE     eq, ne                    Window title
    MODULES         eq, ne                    DLL name

NOTE: "WINDOWTITLE" and "STATUS" filters are not supported when querying
      a remote machine.

Examples:
    TASKLIST
    TASKLIST /M
    TASKLIST /V /FO CSV
    TASKLIST /SVC /FO LIST
    TASKLIST /M wbem*
    TASKLIST /S system /FO LIST
    TASKLIST /S system /U domain\username /FO CSV /NH
    TASKLIST /S system /U username /P password /FO TABLE /NH
    TASKLIST /FI "USERNAME ne NT AUTHORITY\SYSTEM" /FI "STATUS eq running"

Post Reply