4

I recently had a problem with sluggish computer and I live in the terminal, so for me, when something's running slow, "top -o cpu" and "ps aux" are my bread and butter.

However, I recently came to realize "ps ax" or "ps aux" or even "sudo ps aux" does not report everything that is running! Here's a screenshot

09:19:59:4.x >> sudo ps aux | grep ruby
mwlang          56026   0.0  0.0  2432784    544 s000  S+    9:20AM   0:00.00 grep ruby

while "top -o cpu" shows many more ruby processes than ps revealed:

PID    COMMAND      %CPU      TIME     #TH    #WQ  #PORT #MREGS  MEM    RPRVT  PURG   CMPRS  VPRVT  VSIZE  PGRP  PPID  STATE    UID  FAULTS      COW       MSGSENT     MSGRECV     SYSBSD
98759  ruby         97.0      146 hrs  4/1    0    26    2166    6746M- 6690M- 0B     4912M+ 14G    16G    98759 95937 running  501  1825673706+ 433946    27876       21          3657509626+
56121  top          30.6      00:37.98 1/1    0    32    50      4556K  4424K  0B     992K   81M    2440M  56121 56065 running  0    141726+     77        37015730+   18507741+   61005+
65751  firefox      26.5      27:21:28 327    2    1620  127495+ 665M+  494M+  0B     2072M- 2097M+ 6568M+ 65751 209   sleeping 501  337985127+  7365361   1438232150+ 728384120+  1310190547+
0      kernel_task  24.7      17:30:56 114/8  0    2     2264-   1554M+ 42M    0B     0B     353M   15G+   0     0     running  0    230799      0         2395811265+ 2205539103+ 0
67397  VirtualBoxVM 9.5       14:16:44 33     2    414   3388    3752M- 3749M- 0B     311M+  3966M  6906M  67397 67389 sleeping 501  5936410+    1677      33684108+   9575366+    1482333672+
66114  iTerm2       3.9       37:01.21 15     7    300+  3953    69M-   52M-   0B     383M+  3754M- 6384M  66114 209   sleeping 501  34791264+   482207    2951194+    2480745+    19502768+
155    WindowServer 0.8       03:38:00 6      2    548   8392    41M-   8652K- 6240K  297M+  289M-  3931M  155   1     sleeping 88   414771723+  180974    712680590+  322777826+  22182449+
53761  ruby         0.4       52:23.73 4      0    25    199     35M+   35M+   0B     136M-  229M   2622M  53761 38807 sleeping 501  65088356+   295       517         14          402881351+
53760  ruby         0.4       52:07.68 4      0    25    204     84M+   84M+   0B     82M-   219M   2612M  53760 38807 sleeping 501  57778074+   297       547         14          402886484+
88414  ruby         0.4       22:43.84 4      0    29    285     26M+   26M+   0B     104M-  202M   2582M  88414 88413 sleeping 501  40989091+   13357     455         15          181255583+
52438  ruby         0.3       52:04.74 4      0    25    198     34M+   33M+   0B     132M-  221M   2614M  52438 13687 sleeping 501  61304412+   292       563         14          404946477+
98760  ruby         0.3       28:41.28 4      0    22    212     26M+   26M+   0B     140M-  202M   2591M  98760 1894  sleeping 501  50362241+   292       332         14          214106774+
98761  ruby         0.2       29:14.84 4      0    22    220     69M+   69M+   0B     102M-  217M+  2606M  98761 1894  sleeping 501  51711254+   289       366         14          214109097+
16594  ruby         0.2       37:33.18 4      0    23    172     19M+   19M+   0B     127M-  201M   2586M  16594 91713 sleeping 501  54332633+   14464     611         12          225383424+
91714  ruby         0.2       42:44.88 4      0    23    170     22M+   22M+   0B     117M-  191M   2576M  91714 91713 sleeping 501  51527159+   663       669         12          253234882+
56139  Atom         0.2       00:01.70 29     2    306   418     26M-   25M-   32K    29M+   355M-  3486M  56139 209   sleeping 501  41846       1829      6374+       2383+       24316+
67389  VBoxSVC      0.2       21:02.13 15     1    174   150     1164K  1004K  0B     27M    114M   2498M  67389 1     sleeping 501  1644959+    466       75656222+   28298673+   121873928+
72668  ruby         0.1       15:01.58 4      0    22    170     16M+   16M+   0B     101M-  159M   2549M  72668 71643 sleeping 501  37670120+   306       308         14          90096237+
94786  Dropbox      0.1       15:56.10 102    2    376   1276    15M-   15M-   0B     138M+  788M   4249M  376   1     sleeping 501  6420536     2758      1205105+    180822      68686708+
103    hidd         0.1       17:53.13 4      1    103   61      684K   456K   0B     5928K  98M    2456M  103   1     sleeping 0    298514      131       78071816+   41250277+   3510198
...

EDIT: After reading the comments, I continued sleuthing. I finally realized I just needed to drop the "grep ruby" and see just what was reported altogether without filtering. It turns out "ruby" is being spawned or forked from another app, called "spring" so for example the above ruby job with PID 98759 top would be reported by ps as:

09:25:41:~ >> ps ax | grep 98759
98759   ??  Rs   8807:46.18 spring app    | 4.x | started 189 hours ago | test mode
56180 s001  R+     0:00.00 grep 98759

I'm still a bit surprised top and ps would not have the same COMMAND reported. Is this a "feature" of OSX or does Linux behave the same?

  • I normally do not use ruby however after starting an instance and using ps aux | grep [r]uby it reports the running instance. Note the use of the square braces with the grep command is so it doesn't show the grep process looking for ruby just the ruby process itself. So it works as expected for me however you might want to include the OS X/macOS version you're using so we can test in that version to see if it's a version related bug. – user3439894 Nov 1 '16 at 16:25
  • ps aux: List all running processes --- ps auxww: List all running processes including the full command string so maybe you get what you expect to get by using auxww – konqui Nov 1 '16 at 17:02

You must log in to answer this question.

Browse other questions tagged .