Created
February 25, 2019 14:00
-
-
Save coffman21/8b74aeabd6437de065635b7326e31f09 to your computer and use it in GitHub Desktop.
Kill ipython kernel of mem exceed 9.5 Gb
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=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