2

How do show the current list of processes and threads currently in the run queue?

That is to say, if my server's load average is 32.1, then there were on the average about 32 processes or threads ready to run at any given point in time over the past few minutes. I would like to find out what they are.

Something like ps axHr should do the trick, but on a server with a load average in the 80 range, it shows only 3 or 4 items.

The best I've come up with is ps axH | grep -v " S", but that seems kludgy and fragile, and not even totally correct.

tylerl
  • 15,055
  • 7
  • 51
  • 72

2 Answers2

2
ps -A -o pid,state,command | awk '{ if ($2 == "R") print }'
 1605 R /usr/bin/skype
30655 R ps -A -o pid,state,command

or use htop and sort(F6) by "S"

or to troubleshoot highload values:

while [ 1 ] ; do ps -A -o pid,state,command | \
   awk '{ if ($2 != "S") print }' | \
   grep -v "ps -A -o pid,state,command" ; sleep 3 ; done
slm
  • 7,615
  • 16
  • 56
  • 76
bindbn
  • 5,211
  • 2
  • 26
  • 24
  • Note that "R" isn't the only "running" state, many times they'll show up as "D", which still affects your load average – tylerl Sep 26 '10 at 09:01
  • 2
    @tylerl - why did you accept this if it doesn't correctly handle all the various states? – slm Dec 05 '14 at 20:58
1

You can add a watch to your command line :

 watch -n 1 "(ps aux | awk '\$8 ~ /D/ || \$8 ~ /R/   { print \$0 }')"
Ali Mezgani
  • 3,850
  • 2
  • 24
  • 36