#!/bin/sh
free -m
echo
sync
echo 3 > /proc/sys/vm/drop_caches
echo 0 > /proc/sys/vm/drop_caches
FREE_RAM=$(free|grep Mem:|awk '{print $4}')
SWAP_SIZE=$(free|grep Swap:|awk '{print $3}')
echo "Free RAM : ${FREE_RAM}"
echo "Used SWAP : ${SWAP_SIZE}"
if [ "${FREE_RAM}" -gt "${SWAP_SIZE}" ]; then
swapoff -a
swapon -a
echo
free -m
else
echo "Not enough Free RAM"
fi
echo
#清空swap需要謹(jǐn)慎
#如果必須這個(gè)做,除了使用上面的腳本外
#干脆就直接
swapoff -a
swapon -a
文章名稱:清空swap
網(wǎng)址分享:
http://weahome.cn/article/jdoedd.html