Skip to content

Instantly share code, notes, and snippets.

@Tardis07

Tardis07/wipe-pts.sh

Created Mar 31, 2020
Embed
What would you like to do?
kill dead ssh session
#!/bin/bash
current_pts=`ps ax | grep grep | awk '{print $2}'`
echo "current pts is : $current_pts"
w | grep pts | grep -v $current_pts | awk '{print $2}' | while read line
do
echo $line
pid=`ps -ft $line | grep -v UID | awk '{print $2}'`
sudo kill -s 9 $pid
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment