#!/bin/bash # Turn off swap echo "Executing swapoff..." sudo /sbin/swapoff -a # Wait until swap is fully off while [ $(free | grep Swap | awk '{print $3}') -gt 0 ]; do echo "Waiting for swapoff to complete..." sleep 5 done # Wait an additional 30 seconds echo "Swapoff completed. Waiting for 30 seconds..." sleep 30 # Turn swap back on echo "Executing swapon..." sudo /sbin/swapon -a