Just in case this helps someone else — most people are here because they have some stopped processes that they started, backgrounded via the shell maybe. I needed to find processes, as root, stopped by other users, for which variants on the jobs command won’t do.

A bit of digging around with man ps got me to this:

ps -a -o pid,user,cmd,state | grep 'T$'

Explanation: the -a flag says show all processes, then -o controls output, what info will be shown about each process. I’m choosing pid, user, cmd (the command line), and state, which is the process state.

From man ps:

   Here are the different values that the s, stat and state output specifiers (header "STAT" or "S") will display to describe the
   state of a process:
           D    uninterruptible sleep (usually IO)
           R    running or runnable (on run queue)
           S    interruptible sleep (waiting for an event to complete)
           T    stopped, either by a job control signal or because it is being traced
           W    paging (not valid since the 2.6.xx kernel)
           X    dead (should never be seen)
           Z    defunct ("zombie") process, terminated but not reaped by its parent

so finally I pipe it to grep T$ which says, show me all the processes that have T in the last column.

And then I have a nice list of all the processes from different users that are in the stopped state.

$ ps -a -o pid,user,cmd,state | grep 'T$'
  865 joson74+ python                      T
  885 joson74+ sh -c less                  T
  886 joson74+ less                        T
 1014 minames+ python3.4 -i /home/minames  T
 5352 MooKo    nano stdio.h                T
 7851 harry    tmux attach                 T
12083 harry    tmux attach                 T
13495 gorylla+ python3.4 -i /home/gorylla1 T
18009 conr1d   vim                         T
19664 enythin+ python                      T
24906 wardlist python                      T

Leave a Reply

Your email address will not be published. Required fields are marked *