# 查看 core dump 大小限制
ulimit -c
# 查看详细限制
ulimit -a
# 查看 core dump 文件位置
cat /proc/sys/kernel/core_pattern
# 设置 core dump 文件大小(当前会话)
ulimit -c unlimited
# 或设置具体大小(单位:KB)
ulimit -c 1024000
sudo vim /etc/security/limits.conf
# 添加以下行
#* soft core unlimited
#* hard core unlimited
echo "ulimit -c unlimited" >> /etc/profile
# 设置 core dump 文件路径和命名格式
sudo sysctl -w kernel.core_pattern=/tmp/core-%e-%p-%t
# 永久设置,编辑 /etc/sysctl.conf
echo "kernel.core_pattern=/tmp/core-%e-%p-%t" >> /etc/sysctl.conf
#%e - 程序名
#%p - 进程 PID
#%t - 时间戳
#%u - 用户 ID