从程序中,您可以使用它setrlimit(RLIMIT_CORE, ...)来设置核心文件的最大大小.指定无限大小的传递RLIM_INFINITY.
有关详细信息,请阅读此处:http://manpages.debian.net/cgi-bin/man.cgi?query = getrlimit&sektion = 2
使用sysctl您可以执行的命令
sysctl kernel.core_pattern=/var/core/core.%p
Run Code Online (Sandbox Code Playgroud)
有内核创建一个名为内核core.<pid>在/var/core.
添加kernel.core_pattern=/var/core/core.%p到/etc/sysctl.conf使其永久化.(运行sysctl -p以处理您的更改/etc/sysctl.conf)
此外%p(对于进程ID)还有其他占位符如下(取自此处):
%% a single % character
%p PID of dumped process
%u (numeric) real UID of dumped process
%g (numeric) real GID of dumped process
%s number of signal causing dump
%t time of dump, expressed as seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)
%h hostname (same as nodename returned by uname(2))
%e executable filename (without path prefix)
%E pathname of executable, with slashes ('/') replaced by exclamation marks ('!').
%c core file size soft resource limit of crashing process (since Linux 2.6.24)
Run Code Online (Sandbox Code Playgroud)