Skip to content

Instantly share code, notes, and snippets.

@gbraccialli
Created October 28, 2020 16:20
Show Gist options
  • Save gbraccialli/b8826a884d83a9a22f9b7f7e78e8e0da to your computer and use it in GitHub Desktop.
Save gbraccialli/b8826a884d83a9a22f9b7f7e78e8e0da to your computer and use it in GitHub Desktop.
#(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