临时修改:
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 = /disk1/corefile/core.%t.%e.%p.%s
kernel.core_uses_pid = 1
运行sysctl -p,使之生效
mkdir -p /disk1/corefile
说明:
第一个设置,标示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
本文介绍如何临时及永久配置Linux系统中的Core Dump文件。通过修改配置文件可以实现对Core文件大小的控制、路径指定以及文件名格式自定义等功能,有助于更好地进行故障诊断。
1122

被折叠的 条评论
为什么被折叠?



