Limit the output of the TOP command to a specific process name

后端 未结 17 2667
臣服心动
臣服心动 2020-12-12 09:48

If you call the top command, you get all the running processes. But how can I limit the output only to a certain process name like \"java\"?

I\'ve

17条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-12 10:20

    The following code updates a list of processes every 5 seconds via the watch command:

    watch -n 5 -t top -b -n 1 -p$(pgrep java | head -20 | tr "\\n" "," | sed 's/,$//')

提交回复
热议问题