threadStatus.sh 572 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. ROOT=$(cd `dirname $0`/../../; pwd)
  3. cd $ROOT
  4. APP_NAME=blackbox-insert
  5. JAVA_HOME=$ROOT/jdk8
  6. JAR_NAME=$ROOT/lib/insert-app-0.0.1-SNAPSHOT.jar
  7. #PID 代表是PID文件
  8. PID=$ROOT/pid/$APP_NAME\.pid
  9. get_pid(){
  10. pid=`ps -ef|grep $JAR_NAME|grep -v grep|awk '{print $2}' `
  11. #如果不存在返回1,存在返回0
  12. if [ -z "${pid}" ]; then
  13. return 1
  14. else
  15. return 0
  16. fi
  17. }
  18. get_pid
  19. if [ $? -eq "0" ]; then
  20. echo ">>> ${JAR_NAME} is running PID is ${pid} <<<"
  21. #ps -fT -p ${pid}
  22. top -H -p ${pid}
  23. else
  24. echo ">>> ${JAR_NAME} is not running <<<"
  25. fi
  26. exit 0