我正在尝试从我的rootfs提供对coredump文件生成的支持,我已经使用“ulimit -c unlimited”命令和“* hard core -1”修改了/etc/limits文件,现在当我给出kill -6 $$时,期望生成核心文件,但要获取此核心文件必须显式运行 ulimit -c unlimited 。
但我希望它自动发生,不需要在 shell 中再次运行 ulimit -c unlimited 。
谁能告诉我我必须做出哪些改变才能发生同样的事情
从您可以使用的程序setrlimit(RLIMIT_CORE, ...)
设置核心文件的最大大小。指定无限大小的通道RLIM_INFINITY
.
有关详细信息,请阅读此处:
使用sysctl
你可以执行的命令
sysctl kernel.core_pattern=/var/core/core.%p
让内核创建名为的核心core.<pid>
in /var/core
.
Adding kernel.core_pattern=/var/core/core.%p
to /etc/sysctl.conf
使其永久化。 (跑步sysctl -p
处理您的更改/etc/sysctl.conf
)
Besides %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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)