以查询Apache进程为例
1
2
3
4
5
6
|
[root@openvas ~]# ps -ef |grep httpd |sort -r -k 8 |tail -5
apache 19785 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19784 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19778 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19762 4416 0 16:28 ? 00:00:00 /usr/sbin/httpd
root 21078 11822 0 23:34 pts/0 00:00:00 grep httpd
|
1. 使用-v选项
$ps -ef |grep httpd |grep -v grep
1
2
3
4
5
6
|
[root@openvas ~]# ps -ef |grep httpd |grep -v grep |sort -r -k 8 |tail -5
apache 19787 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19785 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19784 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19778 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19762 4416 0 16:28 ? 00:00:00 /usr/sbin/httpd
|
2. 结合正则匹配
$ps -ef |grep [h]ttpd
1
2
3
4
5
6
|
[root@openvas ~]# ps -ef |grep [h]ttpd |sort -r -k 8 |tail -5
apache 19787 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19785 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19784 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19778 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd
apache 19762 4416 0 16:28 ? 00:00:00 /usr/sbin/httpd
|
本文转自 xoyabc 51CTO博客,原文链接:http://blog.51cto.com/xoyabc/1695518,如需转载请自行联系原作者