mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-23 05:01:37 +01:00
Improved swap2ram
This commit is contained in:
parent
eca7ba6dc1
commit
c2ff645c71
@ -7,14 +7,19 @@
|
||||
# License: CC0
|
||||
# NOTE: for automation copy me to /etc/cron.daily
|
||||
|
||||
if ! [ $(id -u) = 0 ]; then
|
||||
echo "Please run this script as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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) ..."
|
||||
printf "Swapping $SwapUsed bytes back to RAM ($RAMfree bytes free of $RAMsize bytes total) ... "
|
||||
start=`date +%s`
|
||||
swapoff -a && swapon -a
|
||||
end=`date +%s`
|
||||
|
||||
echo "✔️ Done - running for `expr $end - $start` seconds"
|
||||
echo "DONE (`expr $end - $start` sec.)"
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user