Created
October 28, 2020 16:20
-
-
Save gbraccialli/b8826a884d83a9a22f9b7f7e78e8e0da to your computer and use it in GitHub Desktop.
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
#(crontab -l 2>/dev/null; echo "*/1 * * * * /root/check_memory.sh") | crontab - | |
free=$( free -g | grep "buffers/cache" | awk '{print $4}') | |
if [ "$free" -le 100 ] | |
then | |
echo "memory too high $free, killing `date`" | tee -a /var/log/memory_check.log | |
ps aux --sort -rss | tee -a /var/log/memory_check.log | |
pkill -9 python | |
else | |
echo "memory ok $free free at `date`" | tee -a /var/log/memory_check.log | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment