silb78 silb78 - 1 year ago 178
Linux Question

Bash: kill process by name

I've got many java processes running with different jar files. I want to kill on explicit jar file process.

the following command doesn't work successfully:

sudo kill $(ps -ef | grep example.jar | awk '{print $2}')

It finds the correct PID, but can't kill it.

Answer Source

Try this:

ps -ef | grep PROCESS | grep -v grep | awk '{print $2}' | xargs kill -9

kills all pids matching the search term of "PROCESS".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download