linux 如何生成 core,Linux 生成 core 文件的方法

临时修改:

ulimit -c unlimited

echo "/corefile/core.%t.%e.%p.%s" > /proc/sys/kernel/core_pattern

echo 1 /proc/sys/kernel/core_uses_pid

这样临时修改的项目,如果切换shell,或者机器reboot,则设置失效,下面给出永久设置的方法

永久修改:

文件 /etc/security/limits.conf 增加一行

* soft core unlimited

文件 /etc/sysctl.conf 增加两行

kernel.core_pattern = /corefile/core.%t.%e.%p.%s

kernel.core_uses_pid = 1

运行sysctl -p,使之生效

说明:

第一个设置,标示core 文件的大小

第二个设置,标示出core文件的路径及其文件名

%p - insert pid into filename 添加pid

%u - insert current uid into filename 添加当前uid

%g - insert current gid into filename 添加当前gid

%s - insert signal that caused the coredump into the filename 添加导致产生core的信号

%t - insert UNIX time that the coredump occurred into filename 添加core文件生成时的unix时间

%h - insert hostname where the coredump happened into filename 添加主机名

%e - insert coredumping executable name into filename 添加命令名

第三个设置,标示出是否在文件名中给出进程pid,如果此项设置为1,即使前面那项不加%p,也会在core文件中加入pid

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值