How to enable core dump in CentOS 7

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s