Linux冷门却很重要的命令(二)---pgrep

来源:互联网 发布:net域名名站 编辑:程序博客网 时间:2024/06/05 00:27
pgrep命令以名称为依据从运行进程队列中查找进程,并显示查找到的进程id。每一个进程ID以一个十进制数表示,通过一个分割字符串和下一个ID分开,默认的分割字符串是一个新行。对于每个属性选项,用户可以在命令行上指定一个以逗号分割的可能值的集合。


用法:
#pgrep [选项] [程序名]
pgrep [-flvx] [-n | -o] [-d delim] [-P ppidlist] [-g pgrplist] [-s sidlist] [-u euidlist] [-U uidlist] [-G gidlist] [-J projidlist] [-t termlist] [-T taskidlist] [-c ctidlist] [-z zoneidlist] [pattern]
常用参数
-l 列出程序名和进程ID;
-o 进程起始的ID;

-n 进程终止的ID;


实例:
[zhoutimo@server ~]$ pgrep -lo nginx
28233 nginx
[zhoutimo@server ~]$ pgrep -l nginx
28233 nginx
28341 nginx
28442 nginx
28543 nginx
28644 nginx
[zhoutimo@server ~]$ pgrep -ln nginx
28644 nginx
[zhoutimo@server ~]$ pgrep nginx
28433
28541
28542
28543
28544
另外,对比另外一个ps(ps -ef|grep nginx)命令,显得简单迅速。
2 0
原创粉丝点击