In my current case, i have one jar file which is running on server. When i need to deploy it again, then i need to stop the jar file and run the new jar file using shell script
by doing java -jar xyz.war & it executes the jar file.
But to check the pid i need to check again by using command pgrep -f xyz.jar
it gives the process id. Now how do i store the process id so that i can use it while killing and then run the new jar when deployment is going.
#!/bin/sh
if pgrep -x xyz.jar > /dev/null
then
echo "Running"
else
echo "Stopped"
cd /folder/location
java -jar xyz.jar &
fi
can anyone help me how do i get the process id in the if condition part