How to set the core dump file location (and name)?
To set location of core dumps in CentOS 6 you can edit /etc/sysctl.conf
. For example if you want core dumps in /var/crash
:
kernel.core_pattern = /var/crash/core-%e-%s-%u-%g-%p-%t
Where variables are:
%e is the filename
%g is the gid the process was running under
%p is the pid of the process
%s is the signal that caused the dump
%t is the time the dump occurred
%u is the uid the process was running under
Also you have to add /etc/sysconfig/init
DAEMON_COREFILE_LIMIT='unlimited'
Now apply new changes:
$ sysctl -p
But there is a caveat whit this way. If the kernel parameter kernel.core_pattern is always reset and overwritten at reboot to the following configuration even when a value is manually specified in /etc/sysctl.conf
:
|/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e
In short when abrtd.service
starts kernel.core_pattern
is overwritten automatically by the system installed abrt-addon-ccpp
. There are two ways to resolve this:
Setting
DumpLocation
option in the/etc/abrt/abrt.conf
configuration file. The destination directory can be specified by setting DumpLocation =/var/crash
in the/etc/abrt/abrt.conf
configuration file, andsysctl kernel.core_pattern
's displayed value is a same but actually core file will be created to the directory under/var/crash
.Also if you have SELinux enabled you have to run:
$ semanage fcontext -a -t public_content_rw_t "/var/crash(/.*)?" $ setsebool -P abrt_anon_write 1
And finally restart
abrtd.service
:$ service abrtd.service restart
Stop abrtd service.
kernel.core_pattern
will not be overwritten. - (I've never tested).