Calculate ETA of swapoff


#!/bin/bash

COUNTER=0
SUM=0
while true; do
start=$(free | grep Swap | awk '{print $2}')
sleep 1
end=$(free | grep Swap | awk '{print $2}')
SUM=$((SUM+start-end))
COUNTER=$((COUNTER+1))
AVG_SPEED=$((SUM/COUNTER))
ETA=$((end/AVG_SPEED))
echo "Current speed: $((start-end))/kbps || Freed total: $SUM || Left: $end || Averate speed: $AVG_SPEED/kbps || ETA: $(($ETA / 3600))h $(($ETA / 60))m $(($ETA % 60))s."
done

Leave a Reply

Your email address will not be published. Required fields are marked *