- 获取进程并杀死 ```json echo “omg.jar restart loading”
定义需要杀死的进程关键字
input1=”omg.jar”
PID=ps -ef | grep $input1 | grep -v "cgroup" | grep -v "grep" | awk '{print $2}'
if [ $? -eq 0 ]; then echo “process id:$PID” else echo “process $input1 not exit” exit fi
kill -9 ${PID}
if [ $? -eq 0 ];then echo “kill $input1 success” else echo “kill $input1 fail” fi
- 完整的sh脚本
```json
echo "omg.jar restart loading"
input1="omg.jar"
PID=`ps -ef | grep $input1 | grep -v "cgroup" | grep -v "grep" | awk '{print $2}'`
if [ $? -eq 0 ]; then
echo "process id:$PID"
else
echo "process $input1 not exit"
exit
fi
kill -9 ${PID}
if [ $? -eq 0 ];then
echo "kill $input1 success"
else
echo "kill $input1 fail"
fi
nohup java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8034 -jar omg.jar --server.port=8035 --spring.profiles.active=test --debug=true --log.path=/www/wwwroot/omg/omg-logs >/dev/null 2>&1 &