Skip to content

Instantly share code, notes, and snippets.

@krizex
Created December 18, 2018 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krizex/be78fdf54052fda9f2f1f8b0af77e69c to your computer and use it in GitHub Desktop.
Save krizex/be78fdf54052fda9f2f1f8b0af77e69c to your computer and use it in GitHub Desktop.
#!/bin/bash
### Filename: coredumpshell.sh
### Description: enable coredump and format the name of core file on centos system
# enable coredump whith unlimited file-size for all users
echo -e "\n# enable coredump whith unlimited file-size for all users\n* soft core unlimited" >> /etc/security/limits.conf
mkdir -p /var/coredumps
chmod 777 /var/coredumps
# format the name of core file.
# %% – 符号%
# %p – 进程号
# %u – 进程用户id
# %g – 进程用户组id
# %s – 生成core文件时收到的信号
# %t – 生成core文件的时间戳(seconds since 0:00h, 1 Jan 1970)
# %h – 主机名
# %e – 程序文件名
# for centos7 system(update 2017.4.2 21:44)
echo -e "\nkernel.core_pattern=/var/coredumps/core-%e-%s-%u-%g-%p-%t" >> /etc/sysctl.conf
# suffix of the core file name
echo -e "1" > /proc/sys/kernel/core_uses_pid
sysctl -p /etc/sysctl.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment