Don't know why coredump is disabled by default on centos7.6 as below:
#cat /proc/sys/kernel/core_pattern
core
Enable as follows:
#echo 'kernel.core_pattern=|/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e' > /etc/sysctl.d/50-coredump.conf
#/lib/systemd/systemd-sysctl
#sysctl -a | grep 'kernel.core_pattern'
kernel.core_pattern = |/usr/lib/systemd/systemd-coredump %p %u %g %s %t %e
How to generate coredump on purpose?
Press ctl + \
:
#sleep 100
^\Quit (core dumped)
or use gdb attach a running task and run:
#sleep 100 &
[1] 5121
#gdb -p 5121
(gdb) generate-core-file
warning: target file /proc/5121/cmdline contained unexpected null characters
warning: Memory read failed for corefile section, 8192 bytes at 0x7ffd4d94f000.
Saved corefile core.5121
(gdb)
coredump:
#ls /var/lib/systemd/coredump/
core.sleep.0.f4b677edcb284566a56c5e61a621fca5.44660.1555487558000000.xz