Is it possible to get the process id of a standalone java application in unix when we run java -jar
command. I am using this command to start the application
java -jar application.jar > application-console.out 2>&1 &
and to get the process id I am using this command
processID=$(ps aux | grep 'application.jar' | grep -v 'grep' | awk '{print $2}')
but my problem is the previous command will search any java jar process for the application.jar but what I am looking for is the one that has been just started.
The PID of the last executed command is in the $!
shell variable:
java -jar application.jar > application-console.out 2>&1 &
echo $!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments