How to enable core and change core path


how to enable core and change core path?
So far I have used the document per RH and CentOS but still I can’t get any core dumped.


Have you tried using the abrt service ?

See DumpLocation parameter in /etc/abrt/abrt.conf to change the default location /var/spool/abrt. Note that the configuration file mentions that changing the location could cause problems with SELinux.


I am using Rocky minimal and I don’t want to install abrt

Change the limit for core dumps to more than the default 0:
ulimit -c unlimited

Set this kernel parameter:
sysctl kernel.core_pattern=/var/tmp/core.%p

Or any other path.

Another way is to let the kernel parameter to its default value: |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e

The core files go to /var/lib/systemd/coredump. It can be changed by configuration.

I have already set the core path, please se below:

[root@node1 crash]# sysctl -p
kernel.core_pattern = /var/crash/core_%e_%p_%h_%t
kernel.core_uses_pid = 1
fs.suid_dumpable = 2

but actually it seems that core size is limited, tough I have the setting "DefaultLimitCORE=infinity" in file /etc/systemd/system.conf, cause if I run ulimit -c unlimited as you suggested, it works.
So to me it’s not clear how to make it unlimited once for all, cause what is suggested in the following RH document doesn’t seem to work:

How to enable core file dumps when an application crashes or segmentation faults

On my system:

# sysctl kernel.core_pattern=/var/tmp/core.%p
kernel.core_pattern = /var/tmp/core.%p

# grep DefaultLimitCORE /etc/systemd/system.conf

# ulimit -c

# sleep 60 &
[1] 2449

# kill -3 2449
[1]+  Quit                    (core dumped) sleep 60

# ls -l /var/tmp/core.*
-rw-------. 1 root root 385024 Jun 27 21:25 /var/tmp/core.2449

But it’s true that DefaultLimitCORE does not work in a minimal installation. A solution is to add such a line in: /etc/security/limits.conf:

*               -       core            unlimited