How to enable core files on CentOS 6

7,614

Solution 1

If your program is running as root, then the limits.conf entries you added would not apply. "*" applies to all users except for root.

If your program is running as root, add the following:

root     hard    core    unlimited
root     soft    core    unlimited

Also, ensure that SELinux is not preventing the writing of the core dump.

getenforce

If SELinux is running, verify that audit is running, try to get your core dump and then do:

grep -i denied /var/log/audit/auditd

Solution 2

The problem probably is that the path is quoted for core_pattern. Try this instead:

kernel.core_pattern = /srv/core/%p_%t.core
Share:
7,614

Related videos on Youtube

Kabb5
Author by

Kabb5

Updated on September 18, 2022

Comments

  • Kabb5
    Kabb5 almost 2 years

    I am trying to enable core files on a machine running CentOS 6; however, nothing I have tried has produced core files…here is what I have done:

    Added the following two lines to /etc/security/limits.conf:

    *     hard    core    unlimited
    *     soft    core    unlimited
    

    Added the following line to /etc/sysconfig/init:

    DAEMON_COREFILE_LIMIT='unlimited'
    

    Added the following line to /etc/profile:

    ulimit -c unlimited > /dev/null 2>&1
    

    Added the following lines to /etc/sysctl.conf:

    kernel.core_pattern = '/srv/core/%p_%t.core'
    fs.suid_dumpable = 1
    

    I made sure that /srv/core exists and has 777 permissions. The I executed init 6 to reboot the OS. Upon the system coming back up, I executed the following C script in an attempt to produce a core file:

    #include <sys/types.h>
    #include <unistd.h>
    #include <signal.h>
    
    int main(int argc, char **argv) {
      kill(getpid(), SIGQUIT);
    }
    

    It does not produce a core file :(

    What am I missing or doing wrong? Thanks in advance for your help!

    • Admin
      Admin about 10 years
      Is the missing ' at the end of the line for /etc/sysconfig/init a bad copy/paste or is it really missing?
    • Kabb5
      Kabb5 about 10 years
      Just a copy/paste error…fixed that in the question
    • user1174838
      user1174838 about 10 years
      I'd change your file mode from 777 to 1777 to prevent 'accidental' deletion of one users core files by another...
    • c4f4t0r
      c4f4t0r about 10 years
      can you show ulimit -a ?