status.sh 643 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env bash
  2. set -e
  3. cat << 'LOGO'
  4. ----------------------------------
  5. LOGO
  6. base_dir=$(
  7. cd "$(dirname "$0")"
  8. pwd
  9. )
  10. cd $base_dir
  11. server_pid=$(pgrep -x watch-daemon || true)
  12. if [[ $server_pid == "" ]]; then
  13. echo "watch-daemon 未在运行"
  14. else
  15. for pid in $server_pid; do
  16. running_time=$(ps -o etime= -p "$pid")
  17. ports=$(ss -tnlp | grep watch-daemon | awk '{print $4}')
  18. echo "watch-daemon 当前PID: $pid"
  19. echo "当前运行时间: $running_time" | tr -s " "
  20. echo "当前运行端口:"
  21. for port in $ports; do
  22. echo "$port"
  23. break
  24. done
  25. done
  26. fi