2020年6月8日09:03:12更新 一些细节。
日常操作linux 中,通常在使用 ps命令后 用管道连接 查询特定进程会显示 grep进程本身。
如下:
1 [root@ecs-linux-byx ~]#ps -ef|grep gs4
2 root 6284 5879 0 14:30 pts/0 00:00:00 grep --color=auto gs4
1 [root@ecs-linux-byx gs4]#ps axu |grep gs4
2 root 2480 0.0 0.0 112728 972 pts/0 S+ 14:20 0:00 grep --color=auto gs4
上述查询,查询结果其实 都是没有 gs4这个进程。但是都显示了 grep进程的本身。
这样,对于初学者,可能并不太友好。有的人会认为这就是自己想要的 进程,结果用 kill -9 PID 时提示进程号不存在.......
如何判断时 grep进程本身? 看下方指令,你就会明白了。(橙色标注。)
进程号一直的变的那个进程是 grep进程本身,正常进程号 也就是PID不会变。
1 [root@ecs-linux-byx ~]#ps -ef|grep gs4
2 root 16455 9998 0 16:19 pts/0 00:00:00 grep --color=auto gs43 [root@ecs-linux-byx ~]#ps -ef|grep gs4
4 root 16493 9998 0 16:19 pts/0 00:00:00 grep --color=auto gs45 [root@ecs-linux-byx ~]#ps -ef|grep gs4
6