可以在/etc/sysctl.conf里设置。

%e: 可执行文件名
%p: 进程的PID
%u: real uid of the process
%g: real gid of the process
%t: the time when the core is dumped
%h: host name
%c: the max size of the core dump file
在上面的设置下,如果一个名为 test的程序产生了core dump, 则他的名字为 test.core.123 (这里假设其pid为 123)
如果在 sysctl.conf里改变了设置,之后要执行 sysctl -p 使之生效。
设置生成压缩的 core文件
首先,创建文件 core_helper:

修改 sysctl.conf文件内容:
#cat etc/sysctl.conf
kernel.core_pattern = |/usr/sbin/core_helper %e %p
kernel.core_uses_pid = 0
#cat /proc/sys/kernel/core_pattern
|/usr/sbin/core_helper %e %p
重新执行 sysctl -p 之后,就会生成 test.core.1234.gz 这样的文件。
man core 里有对于这个管道符号的解释:

-
Linux
+关注
关注
88文章
11628浏览量
217983 -
文件
+关注
关注
1文章
587浏览量
25917 -
虚拟机
+关注
关注
1文章
968浏览量
30178
发布评论请先 登录
如何共享文件给虚拟机中的Linux系统
使用VMware给虚拟机安装linux系统
VMware虚拟机和主机传输文件
linux虚拟机使用教程
虚拟机linux怎么编写程序
怎么安装linux虚拟机
虚拟机数据恢复—EXT4文件系统下KVM虚拟机数据恢复案例

虚拟机:Linux设置core dump文件名的格式
评论