首页 > 系统相关 >java进程占用swap分区问题,导致swap分区快速增满不够用!!

java进程占用swap分区问题,导致swap分区快速增满不够用!!

时间:2022-09-18 17:55:51浏览次数:89  
标签:java 分区 Free awk swap grep

 

for i in $( cd /proc;ls |grep "^[0-9]"|awk ' $0 >100') ;do awk '/Swap:/{a=a+$2}END{print '"$i"',a/1024"M"}' /proc/$i/smaps 2>/dev/null ; done | sort -k2nr | head -10

 

 写脚本swap_free.sh

#!/bin/bash
Free_swap=`free -h | awk '/Swap/{print $NF"M"}'`
Free_swap2=${Free_swap%%MM}
Max_size=$((200 * 1))
if [ ${Free_swap2} -le ${Max_size} ];then
kill -9 `ps -ef|grep java|grep -v grep|awk '{print $2}'`
fi

 

 

 

 从下面可以看出,swap分区恢复正常!!

 

标签:java,分区,Free,awk,swap,grep
From: https://www.cnblogs.com/cherishthepresent/p/16705346.html

相关文章