使用ps aux进程ID

我是shell编程的新手。 假设我已经从我的终端启动了一个程序(例如NetBeans),如果我打字的话

ps aux|grep netbeans 

我得到了输出

 pre 18775 1.2 0.0 12524 1972 pts/3 S 20:17 0:00 

其中18775指定进程的PID等。

然后我用它杀了它

 kill 18775. 

NetBeans UI消失的位置。 如果我尝试使用第一个命令获取pid,我仍然得到:

 pre 19137 0.0 0.0 9136 1068 pts/3 S+ 20:19 0:00 grep --color=auto netbeans 

如果该过程已被杀死,为什么它仍然显示上述输出?

grep正在贪图自己。 尝试以下方法:

 ps aux |grep [n]etbeans 

这使得grep不会在输出中显示出来

切勿psgrep一起使用。

相反,使用killall netbeanspkill netbeans来杀死它。 对于进程ID pgrep netbeans

更多关于ps和grep 。

因为这是grep进程的PID,它排在ps aux之后运行。