#!/bin/bash app_name='bnt-agent.jar' pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2` echo "process id: "${pid} if [[ -z ${pid} ]]; then echo "process killed" else kill -15 ${pid} fi echo "sleep 10s and wait process killed" sleep 10 pid=`ps aux | grep ${app_name} | grep -v 'grep' | tr -s ' '| cut -d ' ' -f 2` if [[ -z ${pid} ]]; then echo "${app_name} has killed" else echo "process ${pid} not killed" fi