19

When I do 'top', I learn that there are many processes running out of which many are in sleep state. I need to see complete snapshot of all processes at that point. the 'top' is able to show listing of processes, which fit in one screen.How do I get complete listing?

Among other things, I am interested in seeing list of all processes, which are in "sleeping" state. I don't think, I can get process state in output of "ps" command

1
  • 1
    See if you have htop. Its process list is scrollable. Commented Apr 11, 2012 at 12:13

2 Answers 2

21

top -b seems to be doing the trick.

3
  • 2
    Adding -n1 option will gives one full page then exit. Commented Apr 11, 2012 at 13:03
  • 2
    Unfortunately this does not allow interactive operation. Commented Jul 14, 2014 at 11:42
  • 1
    Note: although the question was tagged linux, top -l1 works in OS X/macOS to list all processes with states, although %CPU will be incorrect for a single sample with -l, as it is calculated using the delta between samples. Commented Nov 29, 2016 at 14:25
7

You can get process states with coreutils ps

$ ps aux 

will list all that, and more. Here's how you can decode them, from the man page:

PROCESS STATE CODES

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. 

For BSD formats and when the stat keyword is used, additional characters may be displayed:

 < high-priority (not nice to other users) N low-priority (nice to other users) L has pages locked into memory (for real-time and custom IO) s is a session leader l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) + is in the foreground process group. 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.