helper: Print pid of killed mosh sessions
This commit is contained in:
parent
d2afe13425
commit
bbecc3abd1
1 changed files with 4 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue