记程序意外中断不生成core文件

ulimit -c 0 不产生core文件
ulimit -c 100 设置core文件最大为100k
ulimit -c unlimited 不限制core文件大小

默认Centos系统 没做初始化时,limit的配置是这样的

[root@cloud ~]# 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) 3706
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
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) 3706
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
[root@cloud ~]# 
[root@cloud ~]# tail -n 2 /etc/security/limits.d/90-nproc.conf 
*          soft    nproc     1024
root       soft    nproc     unlimited
[root@cloud ~]# 

修改后:

# End of file
@users soft nofile 100001
@users hard nofile 100002
@root  soft nofile 100001
@root  hard nofile 100002
##set limits
*       soft    nproc   50000
*       hard    nproc   50000
*       soft    nofile  50000
*       hard    nofile  50000
*       soft    core    unlimited
*       hard    core    unlimited
comments powered by Disqus