From 59d38975e35356c4a2433b66a4a16e31ec338a7b Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Fri, 8 Sep 2023 15:25:05 +0100 Subject: [PATCH] - avoid 2nd copy of agent --- run_agent.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/run_agent.sh b/run_agent.sh index c0d9fba..d51d97b 100755 --- a/run_agent.sh +++ b/run_agent.sh @@ -3,6 +3,12 @@ # Oneliner to find script's directory. Please note - last path component should NOT be symlink. SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )"; +for pid in $(pidof -x run_agent.sh); do + if [ $pid != $$ ]; then + echo "[$(date)] : run_agent.sh : Process is already running with PID $pid. Exiting." + exit 1 + fi +done while : do