首页 技术 正文
技术 2022年11月23日
0 收藏 938 点赞 4,870 浏览 1591 个字

 http://blog.csdn.net/ctthuangcheng/article/details/8963551

linux core文件设置

分类: Linux OS Debugging Technique2013-05-23 09:51 1446人阅读 评论(0) 举报

在Linux中,一般当进程非正常退出时,会生成一个core文件,这个文件是进程猝死时内存的转储文件,也称为core dump。

查看Linux脚本解析方式:

echo $0

1.检验core是否打开

以see/see登录

csh:  limit;    coredumpsize = 0 , 说明没有打开core, 否则打开了。

linux core文件设置

bash: ulimit –a ;  关注红色部分。 如果是0,表示core没有打开,否则打开了。

linux core文件设置

2.开启core,设置大小

如果没有开启,永久开启

······以root/huawei用户登录,vi /etc/security/limits.conf ,注意红色部分

soft  <  hard大小

linux core文件设置

临时指定大小,以see/see用户登录,

csh: limit coredumpsize 4096000

bash: ulimit -c 4096000  大小低于/etc/security/limits.conf中设置的大小

注意:这些都是临时的,一旦该活跃窗口关闭后再次打开,设置的core大小就失效了。

3. core路径配置

注意:指定的core路径有写入权限

以see/see用户登录,/sbin/sysctl -a |grep core, 查看目前core文件生成的路径

然后肉眼查一下 kernel.core_pattern 和 kernel.core_uses_pid 两个配置值是多少。

kernel.core_pattern: core文件路径

kernel.core_uses_pid: 生成core文件,后缀是否带pid  1:带; 0 :不带

临时修改路径(需要root权限)

/sbin/sysctl -w kernel.core_pattern=/core/core.%e.%p

/sbin/sysctl -w kernel.core_uses_pid=0

%p – insert pid into filename  —   显示进程号

%u – insert current uid into filename —  用户ID

%g – insert current gid into filename —  组ID

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

%t – insert UNIX time that the coredump occurred into filename — 时间

%h – insert hostname where the coredump happened into filename — 主机名

%e – insert coredumping executable name into filename  — 名字

永久修改路径(需要root权限,机器重新启动也会生效):

修改/etc/sysctl.conf,添加2行即可:

kernel.core_pattern = /core/core.%e.%p

kernel.core_uses_pid = 0

设置生效
sysctl -p /etc/sysctl.conf

4. 产生core(用于自测试)

以see/see用户,ksh;kill -11 $$

5. 定位分析core

gdb  container  core文件

然后:bt

6 .关闭core

临时关闭:

csh: limit coredumpsize 0

bash: ulimit -c 0

注意:这些都是临时的,一旦该活跃窗口关闭后再次打开,设置的core大小就失效了。

永久关闭:

以root/huawei用户登录,vi /etc/security/limits.conf ,注意红色部分为0

linux core文件设置

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,991
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,505
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,349
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,134
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,766
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,844