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

电子说

1.2w人已加入

描述

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

Linux

%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:

Linux

修改 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

打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分