1、如何长期开启core dump功能?
编辑 /etc/profile,在末尾加上命令:
ulimit -c unlimited >/dev/null 2>&1
如果原来文件中有ulimit的相关调用,则直接改那个调用。
2、core dump文件的生成方式:
可以修改 /etc/sysctl.conf 文件,加入以下内容:
kernel.core_uses_pid = 1
kernel.core_pattern = /tmp/core-%e-%s-%u-%g-%p-%t
fs.suid_dumpable = 2
相关解释(英文):
kernel.core_uses_pid = 1 - Appends the coring processes PID to the core file name.
fs.suid_dumpable = 2 - Make sure you get core dumps for setuid programs.
kernel.core_pattern = /tmp/core-%e-%s-%u-%g-%p-%t - When the application terminates abnormally, a core file should appear in the /tmp. The kernel.core_pattern sysctl controls exact location of core file. You can define the core file name with the following template whih can contain % specifiers which are substituted by the following values when a core file is created:
%% - A single % character
%p - PID of dumped process
%u - real UID of dumped process
%g - real GID of dumped process
%s - number of signal causing dump
%t - time of dump (seconds since 0:00h, 1 Jan 1970)
%h - hostname (same as ’nodename’ returned by uname(2))
%e - executable filename