How can I find a specific process with “top” in a Mac terminal

前端 未结 8 1551
执笔经年
执笔经年 2021-02-01 02:18

I\'ve tried top | grep skype for example but it doesn\'t work. I\'m trying to find a specific process by name.

8条回答
  •  梦如初夏
    2021-02-01 02:48

    Tested on MacOSX Mojave. It works a bit different than linux.

    top -pid doesn't expect a comma separated list of pids, it expects only one pid. So I had to changed it a little to work with several pids.

    top -pid $(pgrep -d' -pid ' -f Python)
    

    filter all Python process on top. It essentially becomes something like this:

    top -pid 123 -pid 836 -pid 654
    

提交回复
热议问题