PowerShell/Scripts/swap2ram
Markus Fleschutz 30528b2f2a Added metadata
2020-10-23 08:05:31 +00:00

21 lines
577 B
Bash
Executable File

#!/bin/sh
# Syntax: ./swap2ram
# Description: swaps back to RAM
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
# NOTE: for automation copy me to /etc/cron.daily
SwapUsed=$(LC_ALL=C free | awk '/Swap:/ {print $3}')
RAMsize=$(LC_ALL=C free | awk '/Mem:/ {print $2}')
RAMfree=$(LC_ALL=C free | awk '/Mem:/ {print $4}')
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