From 1cd677f86e0ed410e70e35faf5319d16eae4fd8c Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 22 May 2025 14:53:06 +0200
Subject: [PATCH] add trace run

---
 trace.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 trace.sh

diff --git a/trace.sh b/trace.sh
new file mode 100755
index 0000000..8b9fcf5
--- /dev/null
+++ b/trace.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+myCommand="/opt/snow/snowagent -w /opt/snow/"
+logfile="/tmp/snowagent-trace-$( date +%Y%m%d-%H%M%S ).log"
+
+
+echo "
+
+TRACE RUN
+
+Starting '$myCommand' in backgrund and start strace on its PID.
+A log will be generated: $logfile¨
+
+"
+read -p "Press RETURN to continue or Ctrl+C to abort"
+
+
+sudo bash -c "$myCommand" & 
+
+echo "Searching processes ... "
+ps -ef | grep "$myCommand" | grep -v "bash"
+pid=$( ps -ef | grep "$myCommand" | grep -v "bash" | head -1 | awk '{ print $2 }' )
+
+echo "Watching process $pid ..."
+sudo strace -p $pid 2>&1| tee "$logfile"
+
+ls -l "$logfile"
-- 
GitLab