临时修改:
ulimit -c unlimited
echo "/corefile/core.%t.%e.%p.%s" > /proc/sys/kernel/core_pattern
echo 1 /proc/sys/kernel/core_uses_pid
这样临时修改的项目,如果切换shell,或者机器reboot,则设置失效,下面给出永久设置的方法
永久修改:
文件 /etc/security/limits.conf 增加一行
* soft core unlimited
文件 /etc/sysctl.conf 增加两行
kernel.core_pattern = /corefile/core.%t.%e.%p.%s
kernel.core_uses_pid = 1
运行sysctl -p,使之生效
说明:
第一个设置,标示core 文件的大小
第二个设置,标示出core文件的路径及其文件名
%p - insert pid into filename 添加pid
%u - insert current uid into filename 添加当前uid
%g - insert current gid into filename 添加当前gid
%s - insert signal that caused the coredump into the filename 添加导致产生core的信号
%t - insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间
%h - insert hostname where the coredump happened into filename 添加主机名
%e - insert coredumping executable name into filename 添加命令名
第三个设置,标示出是否在文件名中给出进程pid,如果此项设置为1,即使前面那项不加%p,也会在core文件中加入pid