pgrep和top的结合使用,top出指定名称的进程。

1、pgrep xxx

列出进程名包含xxx的:

pgrep -p python

12341
5342
543
21
432
545

列出进程名包含xxx,以逗号,分割输出:

pgrep -d, python

2699,5957,6309,6310,6311,6312,6313,6314,6315,6316,6317,6318,6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329,6402,6403,6404,6405,6406,6407,6408,6409,6410,6411,6412,6413,31766,31767,31768,31769,31770,31771,31772,31773,31774,31775,31776,31777,31778,31779,31780,31781

列出进程全名(含进程参数)中包含xxx,输出用都好分割:

pgrep -f -d, all_span

5957,6308,6309,6310,6311,6312,6313,6314,6315,6316,6317,6318,6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329

2、与top结合,就可以实现top出指定进程(含参数)名中包含xxx的。

top -p $(pgrep -f -d, all_span)

 

Leave a Reply

Your email address will not be published. Required fields are marked *