近日发现个别服务器大量生成core文件,以前一直没有注意这个问题,
经过排查发现,这些服务器设置了 ulimit -c unlimited
经过查找
$HOME/.bash_profile
$HOME/.bashrc
/etc/profile
删除了该命令,通过系统默认的:
vi /etc/profile
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
vi /etc/init.d/functions
corelimit="ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0}"
${DAEMON_COREFILE_LIMIT:-0}表示如果$DAEMON_COREFILE_LIMIT为空则取默认值0.注意 :- 是必须要有的。
core文件 是 core.xxx xxx表示产生异常的pid
可以通过 gdb exefile corefile 进行查看。
相关命令: bt (backtrack) fr num eg., 0 1 2(frame) 等
相关资料如下
HowTo: Debug Crashed Linux Application Core Files Like A Pro
http://www.cyberciti.biz/tips/linux-core-dumps.htmlHOWTO enable core-dumps
http://en.linuxreviews.org/HOWTO_enable_core-dumpsHow do I enable core dumps for everybody
http://www.akadia.com/services/ora_enable_core.html
Linux core dump file详解
http://blog.chinaunix.net/uid-26707720-id-3256694.html
How to Produce a Core File from Your Program
http://sourceware.org/gdb/download/onlinedocs/gdb/Core-File-Generation.html#Core-File-GenerationGDB + Core file dump
http://stackoverflow.com/questions/5150481/gdb-core-file-dump