Skip to content

Instantly share code, notes, and snippets.

@coffman21
Created February 25, 2019 14:00
Show Gist options
  • Save coffman21/8b74aeabd6437de065635b7326e31f09 to your computer and use it in GitHub Desktop.
Save coffman21/8b74aeabd6437de065635b7326e31f09 to your computer and use it in GitHub Desktop.
Kill ipython kernel of mem exceed 9.5 Gb
#!/bin/bash
mem=0
echo '' > '1.lg'
i=0
while true; do
mem=$(free -m | grep Mem | awk {'print $3'})
if [ $i -eq 50 ]; then
date >> '1.lg'
echo $mem >> '1.lg'
i=0
fi
if [ $mem -gt 9500 ]; then
id=$(ps aux | grep [i]pykernel | awk {'print $2'})
kill $id
echo killed >> '1.lg'
fi
i=$((i+1))
sleep 0.1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment