0

I need to select the PID of a Java process. If I run something like this: ps -C java -o pid=, it will select all the Java processes. I am after a specific process where the command used to start is ./java -jar /path/to/my/jar.jar

If I try this: ps -C "./java -jar /path/to/my/jar.jar" -opid= it doesn't work because the selection is not right.

Does anyone know how I can select the PID based on the startup command?

3
ps aux | grep 'java -jar /path/to/my/jar.jar' | grep -v grep | awk '//{print $2}'
  • ps aux | grep '[j]ava -jar /path/to/my/jar.jar' | awk '{print $2}' – Archemar Sep 1 '14 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.