抄了一个脚本,原文:https://blog.csdn.net/m0_37886429/article/details/73826868
test.sh
for i in $(ls /proc | grep "^[0-9]" | awk '$0>100')
do
awk '/Swap:/{a=a+$2}END{print '"$i"',a/1024"M"}' /proc/$i/smaps
done | sort -k2nr | head -n 20 | awk '{print $1}'
使用root用户执行上述脚本,可以打出占用swapfile前20的进程pid
然后可以使用 ps -ef | grep pId命令查到具体的进程信息