kill 掉连接时间超过30分钟的网络连接的进程

kill 掉连接时间超过30分钟的网络连接的进程

ps -e -o pid -o etime -o args|grep LOCAL=NO>/tmp/tmpfile 
cat /tmp/tmpfile|while read LINE 
do 
TIME=`echo $LINE|awk '{print $2}'` 
TIME=`echo $TIME|awk -F: '{print $1}'` 
if [ $TIME -gt 30 ] 
then 
echo $LINE >> /tmp/tmpflie2 
fi 
done 
cut -c 1-5 /tmp/tmpfile2 |xargs -t -n1 kill -9 
rm -f /tmp/tmpfile 
rm -f /tmp/tmpfile2 

猜你喜欢

转载自blog.csdn.net/weixin_43096537/article/details/87367951