歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> 關於Unix >> 殺連接已經超時了的進程(時間大於30分鐘)

殺連接已經超時了的進程(時間大於30分鐘)

日期:2017/3/6 15:29:05   编辑:關於Unix
shell腳本,殺死過期的一些進程,作為以後的參考。

ccff">ps -e -o pid -o etime -o args|grep LOCAL=NO>/tmp/tmpfile
cat /tmp/tmpfile|while read LINE
do
TIME=`echo $LINE|awk ''`
TIME=`echo $TIME|awk -F: ''`
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
然後把這個腳本寫進crontab,讓系統每30分鐘運行一次。

Copyright © Linux教程網 All Rights Reserved