PowerShell/Scripts/swap2ram

21 lines
577 B
Plaintext
Raw Normal View History

2020-07-16 17:39:24 +02:00
#!/bin/sh
2020-10-23 10:05:31 +02:00
# 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}')
2020-10-09 19:13:14 +02:00
RAMsize=$(LC_ALL=C free | awk '/Mem:/ {print $2}')
RAMfree=$(LC_ALL=C free | awk '/Mem:/ {print $4}')
2020-10-23 10:03:03 +02:00
2020-10-09 19:13:14 +02:00
echo "Swapping $SwapUsed bytes back to $RAMsize bytes RAM ($RAMfree bytes free) ..."
2020-10-23 10:03:03 +02:00
start=`date +%s`
2020-07-16 17:39:24 +02:00
swapoff -a && swapon -a
2020-10-23 10:03:03 +02:00
end=`date +%s`
2020-10-09 19:13:14 +02:00
2020-10-23 10:03:03 +02:00
echo "✔️ Done - running for `expr $end - $start` seconds"
2020-07-16 17:39:24 +02:00
exit 0