Skip to content

Instantly share code, notes, and snippets.

@hydra35
Forked from sennajox/update_nproc.sh
Last active December 16, 2015 10:19
Show Gist options
  • Save hydra35/5419608 to your computer and use it in GitHub Desktop.
Save hydra35/5419608 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 3 ];then
echo "usage: $pid $key $value"
exit 1
fi
pid=$1
key=$2
value="${3}ll"
# 修改nproc
# Limit Soft Limit Hard Limit Units
#key=0 Max cpu time unlimited unlimited seconds
#key=1 Max file size unlimited unlimited bytes
#key=2 Max data size unlimited unlimited bytes
#key=3 Max stack size 10485760 unlimited bytes
#key=4 Max core file size unlimited unlimited bytes
#key=5 Max resident set unlimited unlimited bytes
#key=6 Max processes 1024 unlimited processes
#key=7 Max open files 65536 65536 files
#key=8 Max locked memory 65536 65536 bytes
#key=9 Max address space unlimited unlimited bytes
#key=10 Max file locks unlimited unlimited locks
#key=11 Max pending signals 256265 256265 signals
#key=12 Max msgqueue size 819200 819200 bytes
#key=13 Max nice priority 0 0
#key=14 Max realtime priority 0 0
#key=15 Max realtime timeout unlimited unlimited us
# setrlimit第一个参数为 `cat /proc/pid/limits` 后得到的列表中的偏移(从0开始)
gdb -p $pid << EOF >> ulimit.log 2>&1
set \$rlim = &{$value, $value}
p setrlimit($key, \$rlim)
detach
quit
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment