Ubuntu – How to find sleeping process in Ubuntu

command lineprocess

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?

Best Answer

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.