How to enable core dump in CentOS 7?
1. Set the size of core dump to unlimited.
$ ulimit -s unlimited
Confirm it’s configured by
$ ulimit -a
You must see “core file size” is *unlimited*.
[root@hermes ~]# ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
This setting will be gone as session changes. Add the “ulimit -c unlimited” to the /etc/profile in order to survive from session changes.
2. Plan where to store the core dump. I recommend “/var/crash” path.
Allow *write permission* to the the core dump path.
$ chmod 777 <core dump path>
Lots of programs run by other user, which may use setuid. The user MUST have the write permission to the path for core dump.
3. Configure core dump pattern by the path planned at previous step.
By root user, run following
$ echo /var/crash/core-%e-%s-%u-%g-%p-%t > /proc/sys/kernel/core_pattern
In order to keep this for system reboot, add “kernel.core_pattern=/var/crash/core-%e-%s-%u-%g-%p-%t” to the /etc/sysctl.conf