Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to find sleeping processes in Ubuntu?

I can see top can list out number of sleeping processes, but I want them to be listed with their name.

Are there any commands for that?

share|improve this question

Try this:

ps o state,command axh | grep "^[SD]" | cut -b 3-

for listing commands of processes with an interruptable and uninterruptable sleep state.

  • ps outputting only state and commands of all processes (ax) and h removes the header line.
  • grep filters processes other than the two sleep states
  • cut is used to remove the state output again.
  • Optionally replace command with ucmd if you don't need the full name including all arguments.

This is probably suboptimal scripting here, but I couldn't find a quick way to have ps filtered for a specific state.

share|improve this answer
@Thor Thanks for you now removed comment. I've updated my answer. – gertvdijk Sep 15 '12 at 15:30

You could grab the information from top, which can be run in batch mode (-b).

top -bn1 | awk 'NR > 7 && $8 ~ /S|D/ { print $12 }'
  • -n1 top runs only once and exits.
  • NR > 7 skips header.
  • $8 ~ /S|D/ selects programs which are in state D or S.

Possible states are, from top(1):

      'D' = uninterruptible sleep
      'R' = running
      'S' = sleeping
      'T' = traced or stopped
      'Z' = zombie
share|improve this answer
It chops off the first character of the process name; you need to put cut -c40-41,62- instead of cut -c40-41,63- – user76204 Sep 15 '12 at 16:49
It is actually 63 here so using specific column numbers is unreliable. I switched the parsing over to awk. – Thor Sep 15 '12 at 17:12
ps -e S 

will show you sleeping processes.

share|improve this answer
Uhm... no. It will show all processes by providing the -e option. – gertvdijk Mar 31 '14 at 12:48
ps -e S does in fact give you all the processes that are in a Sleep state. Very helpful. – rob Apr 17 '15 at 18:00

Using awk and ps

ps o pid,state,command | \
    awk ' {if ($2 == "T") {printf "%s\t%s\t%s\n","Sleeping",$1,$3};}'


Start mc in a terminal, open a new terminal and start the commands below

kill -STOP $(pgrep mc)
ps o pid,state,command | \
    awk ' {if ($2 == "T") {printf "%s\t%s\t%s\n","Sleeping",$1,$3};}'

Output is

Sleeping    21668   mc
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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