PowerShell/Scripts/swap2ram

17 lines
434 B
Plaintext
Raw Normal View History

2020-07-16 17:39:24 +02:00
#!/bin/sh
2020-10-16 16:37:24 +02:00
#
# NOTE: for automation copy me to /etc/cron.daily
2020-07-16 17:39:24 +02:00
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}')
SwapUsed=$(LC_ALL=C free | awk '/Swap:/ {print $3}')
2020-07-16 17:39:24 +02:00
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