#!/bin/bash pid=`ps -ef | grep short-server-service-1.0-SNAPSHOT | grep -v grep| awk '{print $2}'` if [ -z "$pid" ]; then echo "Application is already stopped" $pid else echo $pid is killed kill -9 $pid fi