0

I'm looking to migrate a monitoring script from Windows (Powershell) to Linux (Shell script). One of the things I check in Windows is whether an application is 'Not Repsonding'. (e.g. Open Task Manager and it says either "Running" or "Not Responding")

Is there an equivalent in Linux, and if so, how do I find it? I've been scouring the web, but can't find anything to say how to find them, only what to do when an application is not responding.

2

In linux, processes can be in different states:

  1. Running(R): This is a state where a process is either in running or ready to run.
  2. Interruptible(S): This state is a blocked state of a process which awaits for an event or a signal from another process
  3. Uninterruptible(D): It is also a blocked state. The process is forced to halt for certain condition that a hardware status is waited and a signal could not be handled.
  4. Stopped(T): Once the process is completed, this state occurs. This process can be restarted
  5. Zombie(Z): In this state, the process will be terminated and the information will still be available in the process table.

You can run "ps" command and "grep" for the states. for eg:

ps aux | awk '{if ($8 ="D") print}'
5
  • ok cheers, that all looks pretty straight forward. All I need to do now then is monitor my application to see which of the above states it ends up.
    – IGGt
    Dec 10 '15 at 11:38
  • 1
    That's not really going to help. Windows defines "not responding" here: windows.microsoft.com/en-us/windows-vista/…. That's a very loose definition - responding "slower than normal"? What's "normal"? Responding to what input? A process that's running in an infinite loop will fall into the Windows definition of "not responding", while it will show up as "running". "Running" doesn't mean it's "responding", while a process that's "interruptible" may be waiting for input and "responding" just fine, or not as it's waiting for something else. Dec 10 '15 at 11:50
  • I agree, it is a very loose term, which we see against some applications quite often. We are moving the applications to run in a wine environment so I just need to figure out what it looks like in Linux when it goes 'not responding'
    – IGGt
    Dec 10 '15 at 16:13
  • How could I use this in a script, where I would need to assign the state to a variable. e.g. echo MyApplicationState="T"?
    – IGGt
    Dec 10 '15 at 16:46
  • This answer needs clarification. For example: a zombie process “will be” terminated when? The answer should also be directed at a broader audience. The question asks for the equivalent of Windows’ “not responding” status. That status is clearly observable to non-specialist users, who can interpret it in useful ways even if they do not know the details of what “not responding” means, but reading this answer did nothing to help me identify processes suffering from problems similar to “not responding”. This is useful to the person who asked the question but not so much to a general audience. Jun 21 '21 at 21:48
0

I found below link for you reference. This is very useful and accurate. It is provided in the Linux manual proc(5).

state  %c
                    One of the following characters, indicating process
                    state:

                    R  Running

                    S  Sleeping in an interruptible wait

                    D  Waiting in uninterruptible disk sleep

                    Z  Zombie

                    T  Stopped (on a signal) or (before Linux 2.6.33)
                       trace stopped

                    t  Tracing stop (Linux 2.6.33 onward)

                    W  Paging (only before Linux 2.6.0)

                    X  Dead (from Linux 2.6.0 onward)

                    x  Dead (Linux 2.6.33 to 3.13 only)

                    K  Wakekill (Linux 2.6.33 to 3.13 only)

                    W  Waking (Linux 2.6.33 to 3.13 only)

                    P  Parked (Linux 3.9 to 3.13 only)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.