Last active
April 5, 2021 10:32
-
-
Save alecdwm/07a23af95cf6d7564401af6d485a6e1a to your computer and use it in GitHub Desktop.
A quick script to check whether your system's current memory usage could fit entirely inside its swap space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A quick script to check whether your system's current memory | |
# usage could fit entirely inside its swap space. | |
# | |
# Might be useful in determining the likelihood of a | |
# successful suspend to disk operation. | |
MEM_USED=$(free -m | grep Mem | awk '{print $3}') | |
SWAP_FREE=$(free -m | grep Swap | awk '{print $4}') | |
if [ ! $MEM_USED -lt $SWAP_FREE ]; then | |
printf "\x1b[31m✗\x1b[0m Mem Used: .$MEM_USED\n .Swap Free:.$SWAP_FREE\n" | |
exit 1 | |
fi | |
printf "\x1b[32m✓\x1b[0m Mem Used: $MEM_USED\n Swap Free: $SWAP_FREE\n" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment