Created
August 3, 2014 14:28
-
-
Save ptrlv/80cf15fdc6f6b42852ee to your computer and use it in GitHub Desktop.
wrapper set_limits
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
function set_limits() { | |
# Set some limits to catch jobs which go crazy from killing nodes | |
# 20GB limit for output size (block = 1K in bash) | |
fsizelimit=$((20*1024*1024)) | |
echo Setting filesize limit to $fsizelimit | |
ulimit -f $fsizelimit | |
# Apply memory limit? | |
memLimit=0 | |
while [ $# -gt 0 ]; do | |
if [ $1 == "-k" ]; then | |
memLimit=$2 | |
shift $# | |
else | |
shift | |
fi | |
done | |
if [ $memLimit == "0" ]; then | |
echo No VMEM limit set | |
else | |
# Convert to kB | |
memLimit=$(($memLimit*1000)) | |
echo Setting VMEM limit to ${memLimit}kB | |
ulimit -v $memLimit | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment