Chinaunix首页 | 论坛 | 博客
  • 博客访问: 610969
  • 博文数量: 244
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 130
  • 用 户 组: 普通用户
  • 注册时间: 2016-06-27 09:53
个人简介

记录学习,记录成长

文章分类

全部博文(244)

我的朋友

分类: LINUX

2015-07-21 22:07:48

pidof

相关命令:ps
pidof 是Linux下用来查找正在运行进程的进程ID (PID)。大部分使用pgrep,ps来替代。

-s 返回多进程,返回一个PID
-c 只返回进程ID
-x 重复命中,返回指定程序的 shell脚本的 pid

-o <进程号>  
      告诉 pidof 忽略带有进程id的进程。 这个特定的pid %PPID能够被用对
      pidof的程序的父亲进程来命名,换句话说就是调用shell或shell脚本.

	

[root@rudder ~]# ps -e|grep httpd      #查看一下,httpd进程
 3546 ?        00:01:04 httpd
16299 ?        00:00:16 httpd
16581 ?        00:00:01 httpd
18796 ?        00:00:14 httpd
20085 ?        00:00:12 httpd
20094 ?        00:00:12 httpd
24664 ?        00:00:03 httpd
24666 ?        00:00:04 httpd
24667 ?        00:00:03 httpd
24708 ?        00:00:02 httpd
27760 ?        00:00:01 httpd

[root@rudder ~]# pidof httpd          #pidof查看
27760 24708 24667 24666 24664 20094 20085 18796 16581 16299 3546

[root@rudder ~]# pidof -s httpd       #只显示一个
27760

[root@rudder ~]# ps -ef |grep /bin/sh    #查看正在运行的shell脚本
root      3859     1  0 May27 ?        00:00:00 /bin/sh /usr/bin/startkde
root     29647 26513  0 12:01 pts/2    00:00:00 grep /bin/sh

[root@rudder ~]# pidof -x /bin/sh        #pidof来查看运行的脚本
26513 18230 3859 

阅读(2367) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~