Setup core dump (Linux)
1. sudo vim /etc/security/limits.conf
#* soft core 0
To
# 1GB
* soft core 1048576
2. Prepare coredump files path
sudo mkdir -p /corefiles && sudo chmod 1777 /corefiles
3. Set coredump enable config and file name pattern
Format of core file name
%%
– 符号%%e
– 程序文件名%t
– 生成core文件的时间戳(seconds since 0:00h, 1 Jan 1970)%p
– 进程号%s
– 生成 core 文件时收到的信号%h
– 主机名%u
– 进程用户 id%g
– 进程用户组 id
Config
sudo vim /etc/sysctl.conf
kernel.core_uses_pid = 1
kernel.core_pattern = /corefiles/%e-%t-%p.coredump
Fix for ubuntu
If system is ubuntu, remove apport
:
sudo apt-get purge apport -y
4. Apply system config
sudo sysctl -p
reboot
5. 查看是否启用了 core dump
ulimit -c
# Or
ulimit -a
临时启用
ulimit -c SIZE
# Or:
ulimit -c unlimited