I am on CentOS 6, trying to enable core dumps for an application I am developing. I have put:

ulimit -H -c unlimited >/dev/null
ulimit -S -c unlimited >/dev/null

in to my bash profile, but a core dump still did not generate (in a new terminal).

I have also changed my /etc/security/limits.conf so that the soft limits is zero for all users.

How do I set the location of the core files to be output? I wanted to specify the location and append the time the dump was generated, as part of the file 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


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:

  1. 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, and sysctl 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
  2. Stop abrtd service. kernel.core_pattern will not be overwritten. - (I've never tested).

  • 1
    Awesome answer. It might be worth noting that on EFI systems you also get a dump in system flash. – mikeserv Mar 27 '15 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.