2、永久修改
1)在配置最后增加2行
cat /etc/sysctl.conf
kernel.core_pattern = /opt/game/core/%e.core.%s.%p.%h.%t
kernel.core_uses_pid = 1
2)永久生效
sysctl -p
3)参数说明
%e executable filename (without path prefix) #dump的文件名
%p PID of dumped process, as seen in the PID namespace in which the process resides #dump的进程PID
%t time of dump, expressed as seconds since the Epoch,1970-01-01 00:00:00 +0000 #转储时刻(由1970年1月1日起计的秒数)
%h hostname (same as nodename returned by uname(2)) #主机名
%s number of signal causing dump #coredump的信号
5、查看到已经有core产生了
ll /opt/game/core/
-rw------- 1 root root 2596864 May 21 02:38 apache2.core.11.2342.10.1.10.117.1432190336
-rw------- 1 www-data www-data 2621440 May 21 02:38 apache2.core.11.2344.10.1.10.117.1432190338
-rw------- 1 www-data www-data 2621440 May 21 02:38 apache2.core.11.2345.10.1.10.117.1432190339
-rw------- 1 www-data www-data 2621440 May 21 02:39 apache2.core.11.2348.10.1.10.117.1432190344
-rw------- 1 www-data www-data 2621440 May 21 02:39 apache2.core.11.2349.10.1.10.117.1432190346
-rw------- 1 www-data www-data 2621440 May 21 02:39 apache2.core.11.2350.10.1.10.117.1432190349
6、使用gdb程序
1)先安装gdb
apt-get -y install gdb
2)使用gdb程序查看
gdb apache2 -core /opt/game/core/apache2.core.11.2342.10.1.10.117.1432190336
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/sbin/apache2...(no debugging symbols found)...done.
[New LWP 2342]
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/usr/sbin/apache2 -k start'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f1d26736433 in select () from /lib/x86_64-linux-gnu/libc.so.6