Process Id Using Ps Aux

I'm a newbie to shell programming. Assuming that I've started a program(eg NetBeans) from my terminal, if I type

ps aux|grep netbeans

I get the the output

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

where 18775 specifies the PID etc of the process.

Then I kill it using

kill 18775.

upon which the NetBeans UI disappears. If I try to get the pid by using the first command, I still get:

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

If the process has been killed, why does it still show the above output?

1

3 Answers

grep is grepping itself. Try something like:

ps aux |grep [n]etbeans

this keeps grep from showing itself in the output

2

Never use ps together with grep.

Rather, use killall netbeans, pkill netbeans to kill it. For the process ID pgrep netbeans.

More on ps and grep.

4

Because that's the PID for the grep process which is queued up to run after ps aux.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest