以查询Apache进程为例
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# 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
时间: 2024-10-13 05:13:36