Top

如何在僅顯示 CMD 名稱的情況下使用 top

  • July 30, 2014

top僅顯示 CMD 名稱如何使用?

我已經習慣top了只顯示我想要的執行過程;例如:

$ top -p 19745

如果我想要多個 PID,我會使用:

$ top -p 19745 -p 19746 -p 19747

我已經用Google搜尋了它,但他們沒有說你怎麼做,即使我嘗試查看它的幫助top仍然沒有告訴你。

有沒有辦法只按 CMD 名稱過濾?

我正在通過 Apache2 執行某些文件,我只想監視它們。

afile1.abc
afile2.abc
afile3.abc
afile4.abc

更新

我在man top頁面中看到了這個:

x: Command  --  Command line or Program name
     Display the command line used to start a task or the name of the associated
     program.   You toggle between command line and name with 'c', which is both
     a command-line option and an interactive command.

     When you've chosen to display command lines, processes  without  a  command
     line  (like  kernel  threads)  will  be shown with only the program name in
     parentheses, as in this example:
           ( mdrecoveryd )

     Either form of display is subject to potential truncation if it's too  long
     to fit in this field's current width.  That width depends upon other fields
     selected, their order and the current screen width.

     Note: The 'Command' field/column is unique, in that it is not  fixed-width.
     When  displayed,  this  column will be allocated all remaining screen width
     (up to the maximum 512 characters) to provide for the potential  growth  of
     program names into command lines.

這對我有什麼用嗎?

如果您top支持過濾,請開始top然後鍵入以下互動式命令:

oCOMMAND=afile

欄位名稱 ,COMMAND必須全部大寫。

從手冊頁:

5e. FILTERING in a Window
  You can use the 'Other Filter' feature to establish selection cri‐
  teria which will then determine which tasks are shown in the ´cur‐
  rent´ window.

  Establishing a filter requires: 1) a field name; 2)  an  operator;
  and  3) a selection value, as a minimum.

  Filter Basics
     .  field names are case sensitive and spelled as in the header
     .  selection values need not comprise the full displayed field
     .  separate unique filters are maintained for each task window

Keyboard Summary
    o  :Other-Filter (lower case)
        You will be prompted to establish a filter that ignores case
        when matching.

    O  :Other-Filter (upper case)
        You will be prompted to establish a case sensitive filter.

引用自:https://unix.stackexchange.com/questions/147446