state Sun Oct 24 09:26:30 PM CEST 2021
This commit is contained in:
parent
5f8f755e6e
commit
65146e772d
2 changed files with 25 additions and 3 deletions
16
kill-old-mosh
Executable file
16
kill-old-mosh
Executable 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue