Skip to content

Instantly share code, notes, and snippets.

@ptrlv
Created August 3, 2014 14:28
Show Gist options
  • Save ptrlv/80cf15fdc6f6b42852ee to your computer and use it in GitHub Desktop.
Save ptrlv/80cf15fdc6f6b42852ee to your computer and use it in GitHub Desktop.
wrapper set_limits
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