| 123456789101112131415161718192021222324 |
- #!/bin/bash
- app_dir=`pwd`
- app_name='devops-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, restart now"
- nohup java -jar ${app_dir}"/"${app_name} ${app_dir}/agent.json > console.log 2>&1 &
- else
- echo "process ${pid} not killed"
- fi
|