linux 配置C++程序的dump文件


1 打开core 开关

vim /etc/security/limits.conf
去掉 soft core 0 一行前面的注释 并将0改为 unlimited

2 修改core产生路径和命名规则

vim /etc/sysctl.conf
最后增加一行
kernel.core_pattern = /data/core/core-%e-%p-%t

可以将core文件统一生成到/cdata/core目录下,产生的文件名为core-命令名-pid-时间戳
以下是参数列表:
%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 添加命令名


3 重启时生效

vim /etc/pam.d/login
增加一行 session required pam_limits.so
session required pam_limits.so

原文地址:https://www.cnblogs.com/lan0725/p/13953148.html