有时候直接在shell执行 ulimit -c unlimited , 还是不会生成 core文件
1) 需要修改 limits.conf
vim /etc/security/limits.conf
* soft core 1000000000 # 1G
* hard core 10000000000 # 10G 安全起见; 也可以设置成 unlimited
2) 另外就是 修改 core-pattern 配置core的格式和路径
vim /etc/sysctl.conf
kernel.core_pattern=core_%e_%p # 不加路径代表就是进程运行目录,查找方便,不过需要注意磁盘空间是否足够; 也可以指定目录 /tmp/core_%e_%p
保存退出 :x
sysctl -p /etc/sysctl.conf 设配置立即永久生效
kill -11 pid 可以测试是否生成core文件
如果 只是本次服务器启动期间有效
echo "/corefile/core-%e-%p" > /proc/sys/kernel/core_pattern
3)以下是摘自linux-2.6.32.59\Documentation\sysctl\kernel.txt
core_pattern:
core_pattern is used to specify a core dumpfile pattern name.
. max length 128 characters; default value is "core"
. core_pattern is used as a pattern template for the output filename;
certain string patterns (beginning with '%') are substituted with
their actual values.
. backward compatibility with core_uses_pid:
If core_pattern does not include "%p" (default does not)
and core_uses_pid is set, then .PID will be appended to
the filename.
. corename format specifiers:
% '%' is dropped
%% output one '%'
%p pid
%u uid
%g gid
%s signal number
%t UNIX time of dump
%h hostname
%e executable filename
% both are dropped .
If the first character of the pattern is a '|', the kernel will treat
the rest of the pattern as a command to run. The core dump will be
written to the standard input of that program instead of to a file.
========================================================================
core_uses_pid:
The default coredump filename is "core". By setting
core_uses_pid to 1, the coredump filename becomes core.PID.
If core_pattern does not include "%p" (default does not)
and core_uses_pid is set, then .PID will be appended to
the filename.
参考链接:
阅读(8577) | 评论(0) | 转发(0) |