From c3a37a7d7dd62d27dbbfb6c4307f1927fa047e67 Mon Sep 17 00:00:00 2001 From: wyyalt Date: Thu, 19 Oct 2023 15:34:50 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8Dgsectl=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E8=8E=B7=E5=8F=96=E8=BF=9B=E7=A8=8B=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98=20(close?= =?UTF-8?q?d=20#1870)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script_tools/gsectl/agent/linux/gsectl | 6 +++--- script_tools/gsectl/proxy/linux/gsectl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/script_tools/gsectl/agent/linux/gsectl b/script_tools/gsectl/agent/linux/gsectl index affb93056..ca1a99d7a 100755 --- a/script_tools/gsectl/agent/linux/gsectl +++ b/script_tools/gsectl/agent/linux/gsectl @@ -641,18 +641,18 @@ get_process_runtime (){ # 找到了匹配的pid # 获取进程pid的启动时间 PID=$_pid - START_TIME=$(ps -eo pid,lstart --sort -start_time | grep "$PID" | awk '{ print $2 " " $3 " " $4 " " $5 " " $6 }') + START_TIME=$(ps -p "$PID" -o lstart=) START_TIME_S=$(date -d "$START_TIME" +%s) CURRENT_TIME_S=$(date +%s) TIME_DIFF=$(($CURRENT_TIME_S - $START_TIME_S)) if [ $TIME_DIFF -le 20 ]; then echo "gse_agent -> $PID has been running for $TIME_DIFF seconds, check $i times" - p_status=0 + p_status=0 break 2 else echo "gse_agent -> $PID has been running for $TIME_DIFF seconds, restart not yet successful, check $i times" - sleep 1 + sleep 1 fi fi done diff --git a/script_tools/gsectl/proxy/linux/gsectl b/script_tools/gsectl/proxy/linux/gsectl index ec46d5bfb..97c62d226 100755 --- a/script_tools/gsectl/proxy/linux/gsectl +++ b/script_tools/gsectl/proxy/linux/gsectl @@ -321,7 +321,7 @@ get_process_runtime (){ # 找到了匹配的pid # 获取进程pid的启动时间 PID=$_pid - START_TIME=$(ps -eo pid,lstart --sort -start_time | grep "$PID" | awk '{ print $2 " " $3 " " $4 " " $5 " " $6 }') + START_TIME=$(ps -p "$PID" -o lstart=) START_TIME_S=$(date -d "$START_TIME" +%s) CURRENT_TIME_S=$(date +%s) TIME_DIFF=$(($CURRENT_TIME_S - $START_TIME_S))