CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS开启coredump转储并生成core文件的配置(centos服务端应用程序开启dump)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

在CentOS或者suse等Linux系统中默认是关闭coredump核心转储的,也就不会产生core文件。由于在C/C++开发中会用到gdb调试,所以需要开启coredump功能。下面是具体的配置命令,可以保存为一个简单的shell脚本执行。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #!/bi

在CentOS或者suse等Linux系统中认是关闭coredump核心转储的,也就不会产生core文件。由于在C/C++开发中会用到gdb调试,所以需要开启coredump功能。下面是具体的配置命令,可以保存为一个简单的shell脚本执行。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

### Filename: coredumpshell.sh
### Description: enable coredump and format the name of core file on centos system

# enable coredump whith unlimited file-size for all users
echo -e "\n# enable coredump whith unlimited file-size for all users\n* soft core unlimited" >> /etc/security/limits.conf

# set the path of core file with permission 777 
cd /mydata && mkdir corefile && chmod 777 corefile

# format the name of core file.   
# %% – 符号%
# %p – 进程号
# %u – 进程用户id
# %g – 进程用户组id
# %s生成core文件时收到的信号
# %t – 生成core文件的时间戳(seconds since 0:00h,1 Jan 1970)
# %h – 主机名
# %e – 程序文件
echo -e "/mydata/corefile/core-%e-%s-%u-%g-%p-%t" > /proc/sys/kernel/core_pattern

# suffix of the core file name
echo -e "1" > /proc/sys/kernel/core_uses_pid

在Linux终端上执行完上面的脚本后,退出并重新登录即可生效。可以通过[root@typecodes ~]# ulimit -a命令查看效果,如下图所示:

本人在centos7中亲测有限,感谢作者。

原创地址:https://typecodes.com/linux/centoscoredumpcfgshell.html

大佬总结

以上是大佬教程为你收集整理的CentOS开启coredump转储并生成core文件的配置(centos服务端应用程序开启dump)全部内容,希望文章能够帮你解决CentOS开启coredump转储并生成core文件的配置(centos服务端应用程序开启dump)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: