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.
Try this:
ps -ef | grep PROCESS | grep -v grep | awk '{print $2}' | xargs kill -9
kills all pids matching the search term of "PROCESS".
you can use killall which allows you to kill processes by name:
killall -ir example.jar
the options:
-i : interactive (asks confirmation for each process whether or not to kill it)-r : allows you to specify a regex. killall will try to kill all matching.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With