ps -aux | less displays
java -jar /var/appname.jar
Now I'm killing it by
killall -9 java
But if there is also another java process java -jar /var/anotherappname.jar how to kill only the first one?
I'd suggest using pkill, with the -f flag to match against the whole command:
pkill -f /var/appname.jar
Test first with
pgrep -af /var/appname.jar
From man pkill:
-f, --full
The pattern is normally only matched against the process name.
When -f is set, the full command line is used.
pgrepto work if it's just a class name, such as one running through the IDE. Anyone have success? e.g.26126 ?? 0:07.15 java [...] com.github.MySillyClass.Searching for the process using
– tresf Oct 09 '19 at 02:45pgrep -af com.github.MySillyClassisn't working.