How to generate core files under Linux environment

  And hang up, it is often difficult to find the cause, but the core Linux kernel files are generally provided us, the process of recording information in a crash when abnormal process under Linux environment. However, core-files need to set the switch, the following steps:

  1, the switch generates a core file to see whether to open, enter the command # ulimit -a

  We see that the first line of core file size is 0, not enabled.

  2, using #ulimit -c [kbytes] may be provided to allow the system generates a core file size;

ulimit -c 0 does not produce core files
 
ulimit -c 100 set core file up to 100k
 
ulimit -c unlimited file size does not limit the core
  Run # ulimit -c unlimited, then ulimit -a view the core

 

  Ben collapse this process can generate core files, this method can only take effect in the shell, said the following about the method of permanent:

  #vim / etc / profile, and then enter the edit mode, adding profile file

ulimit -c unlimited

   Save and exit and restart the server, change file is a long time to take effect, or #source / etc / profile, do not restart the server, use the source file to take effect immediately.

  3. specify the path and name of the generated files; execute # vim /etc/sysctl.conf, enter edit mode, add the following two lines

kernel.core_pattern=/var/core/core_%e_%p
kernel.core_uses_pid=0

  

  Create a directory under the var core, with # sysctl -p /etc/sysctl.conf, it is the changes to take effect immediately.

  core_pattern named parameters are as follows:

% C the maximum size of the dump file

% E the dump file name

The actual group ID% g of the dump process

% H hostname

% P The dump process PID

% S of this signal leads to a coredump

Dump% t time (with effect from January 1, 1970 count the number of seconds)

%u 所dump进程的实际用户ID

  4、# kill -s SIGSEGV $$ ,执行命令,可以看到/var/core下生成了一个core文件,说明已经设置成功。

 

  好了,接下来进程出问题就可以用core文件调试了。

 

 

  

Guess you like

Origin www.cnblogs.com/JohanChan/p/11245723.html