清空swap
#!/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需要谨慎
#如果必须这个做,除了使用上面的脚本外
#干脆就直接
swapoff -a
swapon -a
网页标题:清空swap
文章网址:http://scyanting.com/article/jdoedd.html
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需要谨慎
#如果必须这个做,除了使用上面的脚本外
#干脆就直接
swapoff -a
swapon -a
网页标题:清空swap
文章网址:http://scyanting.com/article/jdoedd.html