Chinaunix首页 | 论坛 | 博客
  • 博客访问: 429949
  • 博文数量: 71
  • 博客积分: 26
  • 博客等级: 民兵
  • 技术积分: 1246
  • 用 户 组: 普通用户
  • 注册时间: 2012-07-23 14:46
个人简介

linux --- 一切皆文件

文章分类

全部博文(71)

文章存档

2021年(1)

2019年(2)

2018年(4)

2017年(7)

2016年(11)

2015年(1)

2014年(2)

2013年(33)

2012年(10)

分类: LINUX

2016-09-12 14:11:50

1:Core文件生成开关
    通过如下命令查看:

点击(此处)折叠或打开

  1. #ulimit -a
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 0
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 50022
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 131072
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 10240
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) 50022
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited

   core file size参数为0表示关闭状态,不会生成core文件。

    通过如下命令开启功能,core文件无大小限制:

点击(此处)折叠或打开

  1. ulimit -c unlimited

2:指定core文件名格式
  默认/proc/sys/kernel/core_pattern参数为core,如果core_uses_pid中的值为0,则生成的所有core文件的名字都是core。
  如果core_uses_pid中的值为1,则生成的core文件的名字为:core.xxx(xxx表示异常进程的pid)

    echo 1 > /proc/sys/kernel/core_uses_pid

  上面的core明显名还不够详细?那可通过如下参数设置/proc/sys/kernel/core_pattern文件
    echo  "core-%e-%p-%t" > /proc/sys/kernel/core_pattern (core文件名:core + 进程文件名 + 进程pid + 生成core文件时间)
    上面的设置,core文件默认生成在执行启动命令的文件夹下。

    参数含义如下:
    %p - insert pid into filename 
    %u - insert current uid into filename 
    %g - insert current gid into filename 
    %s - insert signal that caused the coredump into the filename 
    %t - insert UNIX time that the coredump occurred into filename 
    %h - insert hostname where the coredump happened into filename 
    %e - insert coredumping executable name into filename 

3:core文件生成到指定目录
    echo 1 > /proc/sys/kernel/core_uses_pid
    echo  "/corefile/core-%e-%p-%t" > /proc/sys/kernel/core_pattern
    core文件路径:/corefile/
    core文件名:core + 进程文件名 + 进程pid + 生成core文件时间
阅读(1099) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~