PowerShell/Scripts/swap2ram
2020-10-23 08:03:03 +00:00

17 lines
434 B
Bash
Executable File

#!/bin/sh
#
# NOTE: for automation copy me to /etc/cron.daily
RAMsize=$(LC_ALL=C free | awk '/Mem:/ {print $2}')
RAMfree=$(LC_ALL=C free | awk '/Mem:/ {print $4}')
SwapUsed=$(LC_ALL=C free | awk '/Swap:/ {print $3}')
echo "Swapping $SwapUsed bytes back to $RAMsize bytes RAM ($RAMfree bytes free) ..."
start=`date +%s`
swapoff -a && swapon -a
end=`date +%s`
echo "✔️ Done - running for `expr $end - $start` seconds"
exit 0