Linux – How do I generate a core dump for a daemon in centOS?

How do I generate a core dump for a daemon in centOS?… here is a solution to the problem.

How do I generate a core dump for a daemon in centOS?


have some daemons that crash from time to time and I would like to know how to enable core dump generation.
I know that on linux the ulimit of the core dump is zero by default, so if I want to see the core dump of my running process, I need to set it to unlimited.
But what I want to do is generate a core dump for the daemon running under the root account.
Can anyone tell me how to configure the system? Thank you in advance.


I know, this is a question that is many years old, but it was found for me in a Google search, and the accepted answer is incomplete (at least for Centos).

For RHEL derived systems, most daemons have an init script that provides a script named :


For example, for apache it is:


The environment variables

in these files are read by the init script when the daemon starts, and these variables are used to configure the environment in which the daemon runs.

To enable core dumps, add the following line:

export DAEMON_COREFILE_LIMIT='unlimited'

Restart the daemon after editing this file.

Another thing you might need to do is change the kernel core dump filename template. By default, a core dump is generated in the current working directory and named “core”. This is not very useful, as they will overwrite each other, and in the case of daemons, its working directory may be (a) unknown and (b) non-writable. To change it:

sysctl -w kernel.core_pattern=/tmp/core_%e_%p

The setting is my suggestion and you can change the path and mode of the directory you are using. The above pattern will contain the executable name and pid.

To set it more permanently, edit the file /etc/sysctl.conf and insert:


Related Problems and Solutions