• 获取进程并杀死 ```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

  1. - 完整的sh脚本
  2. ```json
  3. echo "omg.jar restart loading"
  4. input1="omg.jar"
  5. PID=`ps -ef | grep $input1 | grep -v "cgroup" | grep -v "grep" | awk '{print $2}'`
  6. if [ $? -eq 0 ]; then
  7. echo "process id:$PID"
  8. else
  9. echo "process $input1 not exit"
  10. exit
  11. fi
  12. kill -9 ${PID}
  13. if [ $? -eq 0 ];then
  14. echo "kill $input1 success"
  15. else
  16. echo "kill $input1 fail"
  17. fi
  18. 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 &