base-stack/sbin/swap2ram.sh

8 lines
236 B
Bash
Raw Normal View History

2022-11-17 09:47:11 -08:00
#!/bin/bash
err="not enough RAM to write swap back, nothing done"
mem=`free|grep Mem:|awk '{print $4}'`
swap=`free|grep Swap:|awk '{print $3}'`
test $mem -lt $swap && echo -e $err && exit 1
/sbin/swapoff -a && /sbin/swapon -a &&
exit 0