#! /bin/bash MAIN_CLASS=com.demo.JobApplication PID=$(ps -ef|grep -v grep|grep ${MAIN_CLASS}|awk '{print $2}') arr=() for line in ${PID} do arr[${#arr[*]}]=${line} done if [ ${#arr[*]} -eq 0 ] then echo "==========WARN : Process is stopped, skip stop applicatrion==========" exit 0 fi
if [ ${#arr[*]} -gt 1 ] then echo "==========ERROR : Same process more than one, please check you applicatrion==========" exit -1 fi
kill ${arr[0]} if [ $? != 0 ] then echo "==========ERROR : stop fail==========" else echo "==========SUCCESS : stop succeed==========" fi