home: Move mosh cleanup script to local bin
This commit is contained in:
parent
bbecc3abd1
commit
33fb8148b2
1 changed files with 0 additions and 0 deletions
16
home/local/bin/kill-old-mosh
Executable file
16
home/local/bin/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
|
||||
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"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue