user2771655
user2771655

Reputation: 1072

Identify PID from the ps -ef | grep processName

I want to find my oracle weblogic server instance and kill it. When I find the pid I get below. I want to be clear what are these two ids? which one is the correct MyServer process id?

[oracle@xxx ~]$ ps -ef | grep MyServer
oracle    4886  4851  0 16:04 pts/2    00:00:00 grep MyServer
oracle   21759 21700  2 Sep29 ?        09:39:59 /usr/app/oracle/product/jrockit-     jdk1.6.0_29-R28.2.0-4.1.0/bin/java -jrockit -Xms512m -Xmx512m -Dweblogic.Name=MyServer...

Pls help me to understand what is the 4886 and 4851 here in first line of the output.

Can anyone help me?

Upvotes: 0

Views: 1519

Answers (2)

julumme
julumme

Reputation: 2366

Correct way could be to use pgrep:

$ pgrep MyServer

But of course you could also exclude any lines containing the "grep" string as well:

$ ps -ef | grep -v grep | grep MyServer

The grep -v "grep" means "show results that don't contain string "grep" in them

Upvotes: 1

John Zwinck
John Zwinck

Reputation: 249093

4886 is the PID of your own grep command, and 4851 is its parent (your shell).

But you don't need any of this stuff, because:

pkill -f MyServer

Will do the job a lot easier and more efficiently. :)

Upvotes: 1

Related Questions