core文件大小设置 core文件位置设置 sysctl命令修改内核运行配置

2015-12-03 11:09:00
admin
原创 5710
摘要:core文件大小设置 core文件位置设置 sysctl命令修改内核运行配置

一、core文件大小设置

ulimit:Modify shell resource limits,只对当前shell有效。

1、-a,显示所有限制;

2、-S soft,当前用户限制;

3、-H hard,当前用户限制上限;

4、规则1:值以1024-byte为单位;

5、规则2:hard限制必须大于soft限制;

6、规则3:不带S和H参数时,同时设置soft和hard;


print_limit() {

ulimit -c
ulimit -Sc
ulimit -Hc
}


ulimit -Hc unlimited
print_limit
ulimit -c 1000
print_limit
ulimit -Sc 500
print_limit
ulimit -Hc 2000
print_limit


二、core文件位置设置

变量替换规则:

%%  a single % character

%p  PID of dumped process

%u  (numeric) real UID of dumped process

%g  (numeric) real GID of dumped process

%s  number of signal causing dump

%t  time of dump, expressed as seconds since the Epoch

%h  hostname (same as nodename returned by uname(2))

%e  executable filename (without path prefix)

%c  core file size soft resource limit of crashing process


查看core文件位置:cat /proc/sys/kernel/core_pattern

修改core文件位置:echo "core-%e-%p-%t" > /proc/sys/kernel/core_pattern,系统重启后恢复默认;

查看是否使用pid:cat /proc/sys/kernel/core_uses_pid

修改是否使用pid:echo 1 >/proc/sys/kernel/core_uses_pid,文件位置不包含pid时,系统自动添加;


三、sysctl命令修改内核运行配置

1、系统启动时从/etc/sysctl.conf文件加载系统运行时配置;

2、重新加载系统运行时配置:sysctl -p /etc/sysctl.conf;


sysctl - configure kernel parameters at runtime,系统重启后恢复默认:

1、查看core_pattern:sysctl -a | grep core_pattern

2、设置core_pattern:sysctl -w kernel.core_pattern=core-%e-%p-%t

发表评论
评论通过审核之后才会显示。