Greetings Deployment Gods,
I am trying to run a small bash script to stop a process and take a backup of the existing .jar file in a single deployment process step. The script looks something like the following:
#!/bin/bash
PID=$(pgrep -f AppName)
if [ “$PID” == “” ]
then
echo “App is not running.”
else
echo “Attempting to stop the app…”
kill $PID
echo “App stopped”.
fi
#Backup the app
cp app.jar app.jar.bak
It appears to be hitting the ‘kill’ command (successfully stops the app most of the time) but the following echo message doesn’t appear and the backup bit isn’t run either.
Any ideas? Where am I going wrong?
Cheers,
Nelson