先看一下ulimit配置文件的内容,下面只是截取了说明性的部分。
view plaincopy to clipboardprint?
01.# /etc/security/limits.conf
02.#
03.#Each line describes a limit for a user in the form:
04.#
05.#<domain> <type> <item> <value>
06.#
07.#Where:
08.#<domain> can be:
09.# - an user name
10.# - a group name, with @group syntax
11.# - the wildcard *, for default entry
12.# - the wildcard %, can be also used with %group syntax,
13.# for maxlogin limit
14.# - NOTE: group and wildcard limits are not applied to root.
15.# To apply a limit to the root user, <domain> must be
16.# the literal username root.
17.#
18.#<type> can have the two values:
19.# - "soft" for enforcing the soft limits
20.# - "hard" for enforcing hard limits
21.#
22.#<item> can be one of the following:
23.# - core - limits the core file size (KB)
24.# - data - max data size (KB)
25.# - fsize - maximum filesize (KB)
26.# - memlock - max locked-in-memory address space (KB)
27.# - nofile - max number of open files
28.# - rss - max resident set size (KB)
29.# - stack - max stack size (KB)
30.# - cpu - max CPU time (MIN)
31.# - nproc - max number of processes
32.# - as - address space limit (KB)
33.# - maxlogins - max number of logins for this user
34.# - maxsyslogins - max number of logins on the system
35.# - priority - the priority to run user process with
36.# - locks - max number of file locks the user can hold
37.# - sigpending - max number of pending signals
38.# - msgqueue - max memory used by POSIX message queues (bytes)
39.# - nice - max nice priority allowed to raise to values: [-20, 19]
40.# - rtprio - max realtime priority
41.# - chroot - change root to directory (Debian-specific)
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#<domain> <type> <item> <value>
#
#Where:
#<domain> can be:
# - an user name
# - a group name, with @group syntax
# - the wildcard *, for default entry
# - the wildcard %, can be also used with %group syntax,
# for maxlogin limit
# - NOTE: group and wildcard limits are not applied to root.
# To apply a limit to the root user, <domain> must be
# the literal username root.
#
#<type> can have the two values:
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#<item> can be one of the following:
# - core - limits the core file size (KB)
# - data - max data size (KB)
# - fsize - maximum filesize (KB)
# - memlock - max locked-in-memory address space (KB)
# - nofile - max number of open files
# - rss - max resident set size (KB)
# - stack - max stack size (KB)
# - cpu - max CPU time (MIN)
# - nproc - max number of processes
# - as - address space limit (KB)
# - maxlogins - max number of logins for this user
# - maxsyslogins - max number of logins on the system
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
# - sigpending - max number of pending signals
# - msgqueue - max memory used by POSIX message queues (bytes)
# - nice - max nice priority allowed to raise to values: [-20, 19]
# - rtprio - max realtime priority
# - chroot - change root to directory (Debian-specific)
这个配置文件里对各item的解释很详细。
可以通过ulimit命令直接直接在命令行里做一些设置。
比如,在调试段错误的时候,可以设置core的大小来生成core文件。此文件用于gdb调试,能直接定位发生段误的源代码,显示错误所在行的行号及调用出错函数。设置core文件大小的命令直接在命令行输入:
ulimit -c unlimited
但是这个做法仅一次有效,当shell重启后,它将失去效力。再使用ulimit -c 查看,它会恢复默认值。
为了避免这样的情况,可以在配置文件里做修改。这样的话,每次启动shell,配置文件里的内容都会被扫描。
下面只给出core的设置,其他的类似。
view plaincopy to clipboardprint?
01.root soft core unlimited
root soft core unlimited
这样,只要以root身份登陆,那么无论什么时候,在shell下输入 ulimit -c,总是显示 unlimited。除非修改了配置文件,否则将永远不会改变
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/chuaimeng/archive/2010/07/14/5734348.aspx