1234567891011121314151617181920 |
- #!/usr/bin/env bash
- set -e
- app_name="CloudflareServer"
- pid=$(ps -auxw | grep ${app_name} | grep -vE "grep|-Xmx700m" | awk '{print $2}')
- if [[ $pid == "" ]]; then
- echo "${app_name} 未在运行"
- else
- running_time=$(ps -o etime= -p "$pid")
- ports=$(netstat -tnlp | grep ${app_name:0:10} | head -n +1 | awk '{print $4}')
- echo "${app_name}当前PID: $pid"
- echo "当前运行时间: $running_time" | tr -s " "
- echo "当前运行端口:"
- for i in "$ports"; do
- echo "$i"
- done
- fi
|