centos 開啟coredump


在開發中,coredump會輸出珍貴的調試信息,但在linux下默認是關閉的,所以,要手動去把它打開。
執行以下腳本,退出后重新登錄即可,重新登錄后執行ulimit -c,如果出來的是unlimited,就是已經打開了,且不限制coredump生成的core文件大小

#!/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

# set the path of core file with permission 777 
cd /mydata && mkdir corefile && chmod 777 corefile

# format the name of core file.   
# %% – 符號%
# %p – 進程號
# %u – 進程用戶id
# %g – 進程用戶組id
# %s – 生成core文件時收到的信號
# %t – 生成core文件的時間戳(seconds since 0:00h, 1 Jan 1970)
# %h – 主機名
# %e – 程序文件名
echo -e "/mydata/corefile/core-%e-%s-%u-%g-%p-%t" > /proc/sys/kernel/core_pattern

# for centos7 system(update 2017.2.3 21:44)
echo -e "/mydata/corefile/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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM