Chinaunix首页 | 论坛 | 博客
  • 博客访问: 523162
  • 博文数量: 80
  • 博客积分: 1496
  • 博客等级: 上尉
  • 技术积分: 1292
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-18 11:24
个人简介

IT码农一个~

文章分类

全部博文(80)

文章存档

2020年(3)

2019年(7)

2017年(1)

2016年(2)

2015年(2)

2014年(26)

2013年(26)

2012年(2)

2011年(1)

2010年(1)

2008年(9)

我的朋友

分类: LINUX

2020-04-14 16:40:54

有时候直接在shell执行 ulimit -c unlimited , 还是不会生成 core文件

1) 需要修改 limits.conf
vim /etc/security/limits.conf
  *               soft    core             1000000000    # 1G
  *               hard    core            10000000000  # 10G  安全起见; 也可以设置成 unlimited

2) 另外就是 修改 core-pattern 配置core的格式和路径

vim /etc/sysctl.conf
kernel.core_pattern=core_%e_%p   # 不加路径代表就是进程运行目录,查找方便,不过需要注意磁盘空间是否足够; 也可以指定目录 /tmp/core_%e_%p
保存退出 :x

sysctl -p  /etc/sysctl.conf
 设配置立即永久生效

kill -11 pid  可以测试是否生成core文件

如果 只是本次服务器启动期间有效 
echo "/corefile/core-%e-%p" > /proc/sys/kernel/core_pattern

3)
以下是摘自linux-2.6.32.59\Documentation\sysctl\kernel.txt

core_pattern:

core_pattern is used to specify a core dumpfile pattern name. 
. max length 128 characters; default value is "core" 
. core_pattern is used as a pattern template for the output filename;
  certain string patterns (beginning with '%') are substituted with
  their actual values. 
  . backward compatibility with core_uses_pid: 
  If core_pattern does not include "%p" (default does not)
  and core_uses_pid is set, then .PID will be appended to
  the filename. 
. corename format specifiers:
  %  '%' is dropped
  %%  output one '%'
  %p  pid
  %u  uid
  %g  gid
  %s  signal number
  %t  UNIX time of dump
  %h  hostname
  %e  executable filename
  % both are dropped . 
  If the first character of the pattern is a '|', the kernel will treat 
  the rest of the pattern as a command to run.  The core dump will be 
  written to the standard input of that program instead of to a file.
========================================================================
core_uses_pid:
The default coredump filename is "core".  By setting 
core_uses_pid to 1, the coredump filename becomes core.PID. 
If core_pattern does not include "%p" (default does not) 
and core_uses_pid is set, then .PID will be appended to
the filename.

参考链接:


阅读(8423) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~