linux命令--pgrep命令
pgrep 是通过程序的名字来查询进程的工具,一般是用来判断程序是否正在运行。在服务器的配置和管理中,这个工具常被应用,简单明了;
用法:
#ps 参数选项 程序名
常用参数
-l 列出程序名和进程ID;
-o 进程起始的ID;
-n 进程终止的ID;
-U 用户的进程ID;
举例:
# pgrep -lo httpd
4557 httpd
# pgrep -ln httpd
4566 httpd
# pgrep -l httpd
10455 httpd
11443 httpd
11444 httpd
11446 httpd
11448 httpd
11543 httpd
11576 httpd
# pgrep httpd
10455
11443
11444
11446
11448
11543
11576
只打印指定pid的信息
#top -p 'pgrep java|tr "\\n" "," | sed '/s,$//' '

浙公网安备 33010602011771号