stat.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. APP_HOME=$HOME
  3. . "$APP_HOME/conf/setenv.sh"
  4. check_app() {
  5. APP_NAME=$1
  6. PID_FILE="$PID_DIR/$APP_NAME.pid"
  7. echo ""
  8. echo "[INFO] Checking status of $APP_NAME..."
  9. sleep 1
  10. if [ -f "$PID_FILE" ]; then
  11. PID=$(cat "$PID_FILE")
  12. if ps -p "$PID" > /dev/null 2>&1; then
  13. echo "[INFO] $APP_NAME is running (PID: $PID)"
  14. else
  15. echo "[INFO] $APP_NAME PID file exists but process not found"
  16. fi
  17. else
  18. COUNT=$(ps -eaf | grep java | grep "$APP_NAME" | grep -v grep | wc -l)
  19. if [ "$COUNT" -gt 0 ]; then
  20. echo "[INFO] $APP_NAME is running but no PID file found"
  21. else
  22. echo "[INFO] $APP_NAME is not running"
  23. fi
  24. fi
  25. echo ""
  26. }
  27. case "$1" in
  28. utic-ptis-server)
  29. check_app "$1"
  30. ;;
  31. *)
  32. for APP in $APP_LIST; do
  33. check_app "$APP"
  34. done
  35. ;;
  36. esac
  37. echo "[INFO] Checking process information..."
  38. for APP in $APP_LIST; do
  39. echo "Checking $APP"
  40. ps -eaf | grep "$APP" | grep -v grep | grep -v tail | grep java
  41. done
  42. echo ""
  43. ps -eaf | grep java | grep -v grep | grep -v tail
  44. echo ""