From bbecc3abd1ccd19f21e720c2ae99333bd3b5b843 Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Tue, 16 Nov 2021 17:30:24 +0100 Subject: [PATCH] helper: Print pid of killed mosh sessions --- kill-old-mosh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kill-old-mosh b/kill-old-mosh index 52e5a2e..e863abc 100755 --- a/kill-old-mosh +++ b/kill-old-mosh @@ -4,13 +4,13 @@ count=0 while read pid _; do session=$(cat /proc/$pid/sessionid) if [ "$mysession" != "$session" ]; then - kill $pid - count=$((count + 1)) + if kill $pid; then + echo 2>&1 "stale mosh session $pid killed" + count=$((count + 1)) + fi fi done <<<$(ps -C mosh-server -o pid=,etimes= | sort -k 2 -r) if [[ $count -eq 0 ]]; then echo 2>&1 "No stale mosh session found" -else - echo 2>&1 "$count stale mosh session(s) killed" fi