state Sun Oct 24 09:26:30 PM CEST 2021

This commit is contained in:
Alexander Kobjolke 2021-10-24 21:26:30 +02:00
parent 5f8f755e6e
commit 65146e772d
2 changed files with 25 additions and 3 deletions

16
kill-old-mosh Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env bash
mysession=$(cat /proc/self/sessionid)
count=0
while read pid _; do
session=$(cat /proc/$pid/sessionid)
if [ "$mysession" != "$session" ]; then
kill $pid
count=$((count + 1))
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