Last active
December 12, 2015 20:58
-
-
Save hpanago/143f03c21d56a77dbd76 to your computer and use it in GitHub Desktop.
Bash script that notifies you when you free memory is 100 MB. Shows process ID and name.
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 | |
MEM=`cat /proc/meminfo | egrep 'MemFree:' |tr -d '[[:space:]]' | sed '$s/..$//' | cut -d ":" -f2` | |
USER=`whoami` | |
PID=`ps -ly --User $USER --sort -rss | sed -n '2p' | tr -s [[:blank:]] | cut -d " " -f3` | |
NAME=`ps -ly --User $USER --sort -rss | sed -n '2p' | tr -s [[:blank:]] | cut -d " " -f13` | |
if [ $MEM -lt 102400 ]; then | |
DISPLAY=:0 notify-send "Low memory. #1 process in RAM usage: $NAME with PID: $PID" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment