设置 core dump文件名的格式
来源:互联网 发布:青少年禁毒网络大赛 编辑:程序博客网 时间:2024/05/16 05:17
可以在/etc/sysctl.conf里设置。
cat sysctl.conf kernel.core_pattern =%e.core.%pkernel.core_uses_pid = 0
%e: 可执行文件名
%p: 进程的PID
%u: real uid of the process
%g: real gid of the process
%t: the time when the core is dumped
%h: host name
%c: the max size of the core dump file
在上面的设置下,如果一个名为 test的程序产生了core dump, 则他的名字为 test.core.123 (这里假设其pid为 123)
如果在 sysctl.conf里改变了设置,之后要执行 sysctl -p 使之生效。
设置生成压缩的 core文件
首先,创建文件 core_helper:
#cat usr/sbin/core_helper #!/bin/shexec gzip - > /root/$1.core.$2.gz修改 sysctl.conf文件内容:
#cat etc/sysctl.conf kernel.core_pattern = |/usr/sbin/core_helper %e %p kernel.core_uses_pid = 0
#cat /proc/sys/kernel/core_pattern |/usr/sbin/core_helper %e %p
重新执行 sysctl -p 之后,就会生成 test.core.1234.gz 这样的文件。
man core 里有对于这个管道符号的解释:
Since kernel 2.6.19, Linux supports an alternate syntax for the /proc/sys/kernel/core_pattern file. If the first character of this file is a pipe symbol (|), then the remainder of the line is inter‐ preted as a program to be executed. Instead of being written to a disk file, the core dump is given as standard input to the program. Note the following points: * The program must be specified using an absolute pathname (or a path‐ name relative to the root directory, /), and must immediately follow the '|' character. * The process created to run the program runs as user and group root. * Command-line arguments can be supplied to the program (since kernel 2.6.24), delimited by white space (up to a total line length of 128 bytes). * The command-line arguments can include any of the % specifiers listed above. For example, to pass the PID of the process that is being dumped, specify %p in an argument.
0 0
- 设置 core dump文件名的格式
- 定制core dump 文件的文件名
- 定制core dump文件的文件名
- Linux使用笔记: 定制core dump文件的文件名
- gdb设置core dump的总结
- 设置core dump文件生成的方法
- Linux Core Dump设置
- Linux 设置core dump
- core dump 设置
- centos core dump 设置
- core dump 设置
- Linux 设置core dump
- core dump设置(gdb分析)
- linux下core文件设置, Core Dump
- core dump的意义
- core dump 的处理
- Linux系统dameon程序的core dump设置
- 设置Core Dump的目录和命名规则
- C++ 中字面值和 string 对象相加
- Enhancing custom classes 优化自定义类
- UML之九种图分析
- python和FTP
- 不容易系列之(3)—— LELE的RPG难题
- 设置 core dump文件名的格式
- 捷普选定英国电信(BT)为其打造标准化的全球网络IT服务
- AndroidAnnotations——Enhance custom views 优化自定义组件
- 字符统计(杭电1860)
- 爱情的浓度
- Enhancing the Application class 优化Application类
- LA3263 That Nice Euler Circuit 2004_Shanghai 平面上的欧拉定理
- web版电子表格二
- “微品会”是一个类似淘宝式的开店应用