ulimit
說明:顯示/設定使用者、群組等級的shell、process使用的資源限制
使用概念
- 針對本session shell或session shell中的process做設置
- 直接顯示或設定資源限制
- 設定分為soft and hard
- 使用ulimit做的設定,都是暫時性的(只針對本session)
- 全系統的永久性修改,須改 /etc/security/limits.conf
Options
ulimit [-HSTabcdefilmnpqrstuvx [limit]] -H: hard limit 執行緒不能在執行中改變數值(除非有root權限) -S: soft limit 執行緒可在執行中改變數值 不加 -H,-S,默认兩者都设置。 LIMIT 的值,除了可以是数字,也可以是 hard, soft, unlimited hard: 当前 hard 限制值 soft: 当前 soft 限制值 unlimited: 无限制 不加 LIMIT,表示打印对应选项的资源(有多个选项时,会显示资源名和单位): #ulimit -f unlimited #ulimit -c 0 #ulimit -c -f core file size (blocks, -c) 0 file size (blocks, -f) unlimited -a All current limits are reported -b The maximum socket buffer size -c The maximum size of core files created -d The maximum size of a process's data segment -e The maximum scheduling priority ("nice") -f The maximum size of files written by the shell and its children -i The maximum number of pending signals -l The maximum size that may be locked into memory -m The maximum resident set size (many systems do not honor this limit) -n The maximum number of open file descriptors (most systems do not allow this value to be set) -p The pipe size in 512-byte blocks (this may not be set) -q The maximum number of bytes in POSIX message queues -r The maximum real-time scheduling priority -s The maximum stack size -t The maximum amount of cpu time in seconds -u The maximum number of processes available to a single user -v The maximum amount of virtual memory available to the shell and, on some systems, to its children -x The maximum number of file locks -T The maximum number of threads If limit is given, and the -a option is not used, limit is the new value of the specified resource. If no option is given, then -f is assumed. Values are in 1024-byte increments, except for -t, which is in seconds; -p, which is in units of 512-byte blocks; and -T, -b, -n, and -u, which are unscaled values. The return status is 0 unless an invalid option or argument is sup‐ plied, or an error occurs while setting a new limit.
Example
顯示當前user 的open files(n)的hard設定ulimit -Hn 1024顯示當前user 所有設定
ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 31204 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 (file descriptor) pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 31204 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
把當前user的file descriptor數量暫時修改為10240
#ulimit -n 10240
沒有留言:
張貼留言