在 Linux 下某用戶下能否產生 core 文件,產生的 core file size 的等限制,是可以通過修改配置文件
/etc/security/limits.conf 文件里的配置來加以修改。有的時候,系統會在 /etc/profile 之類的文件中
作出全局的配置。例如: 在 SUSE 下的 /etc/profile 經常有如下的缺省設置:
ulimit -Sc 0 # don't create core files
ulimit -Sd $(ulimit -Hd)
ulimit -Ss $(ulimit -Hs)
ulimit -Sm $(ulimit -Hm)
如果希望產生 core,別忘了把這里的設置注釋掉。
按照文件前部的說明,可以在文件中添加類似這樣的行:
username soft core scorefilesize
username hard core hcorefilesize
或
@group soft core scorefilesize
@group hard core hcorefilesize
分別對用戶'username'和組'groupname'設置能否產生 core,產生的 core file size 的限制
占位符scorefilesize
請詳細閱讀文件 /etc/security/limits.conf 的注釋部分
# /etc/security/limits.conf
#
#Each line describes a limit for a user in the form:
#
#Where:
#
# - 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
#
#
# - "soft" for enforcing the soft limits
# - "hard" for enforcing hard limits
#
#
# - 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
# - maxlogins - max number of logins for this user
# - priority - the priority to run user process with
# - locks - max number of file locks the user can hold
#
#
#
原文轉自:http://www.anti-gravitydesign.com