How can I kill a process based on its command line arguments?
killall
, pgrep
, and pkill
seem to only work based on the process name.
I need this to be able to differentiate between a number of applications running inside Java virtual machines, where java
is the process name for all of them and the actual application name can be found by looking at the command line arguments.
This can be done manually with ps aux | grep myapp.jar
and then manually killing the pid from the output, but I'd like a command to do something equivalent automatically.
Best Answer
pgrep
/pkill
take a-f
flag. From theman
page:For example: