Monday, July 21, 2008

How to exit all telnet session at one shot

function stopall
{
if [ $# -eq 0 ]
then
echo "stopall "
echo "1:Kill all the Tail process"
echo "2:Kill all the telnet session(including kill tail process)"
else

if [ $1 -eq 1 ]
then
psef|grep "tail"|awk '{print $2}'|xargs kill -9 2>/dev/null
echo "All Tail process are killed"
elif [ $1 -eq 2 ]
then
psef|grep "tail"|awk '{print $2}'|xargs kill -9 2>/dev/null
psef|grep "ksh"|grep -v `echo $$`|awk '{print $2}'|xargs kill -9 2>/dev/null
kill -9 `echo $$`
else
echo "Please provide correct input"
fi
fi
}

No comments:

Post a Comment