Print this article Edit this article

Limit size of Core Files

Core Files

If you are compiling and running programs, and your program core dumps, remember to delete the file "core" because often it can be a very large file, which will cause you to hit your quota limit. If you are debugging, you can utilize the core file to find errors, but after you are done with it, it should be deleted. Core files are binary files, that are created when a program dies.

If you are running someone else's program, and it creates a filename like "core.###" and you are not sure it that file is a core dump, or part of the program, you can check with the "file" command.

file core.4615
core.4615: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style, SVR4-style, from 'a.out'

This is a core file. 

If you are constantly changing your program, and creating core files is going to be a way of life while you do that, you can always set your coredumpsize to be a small number, and not have to worry about deleting the core file immediately.  At your Unix/Linux command prompt, type "limit".

limit
cputime         unlimited
filesize        unlimited
datasize        unlimited
stacksize       8192 kbytes
coredumpsize    unlimited
descriptors     256
memorysize      unlimited

If you are using csh, this will work. If you are using bash, ksh or sh, you may need to use the command: ulimit
The ulimit command has a different syntax.  For more details type "man bash" (or ksh or sh) and search for "ulimit".

The information displayed by the "limit" command shows that the coredumpsize  is allowed to be as large as the dying program needs to write information to the file "core".

limit coredumpsize 256

Now when you type the command "limit" you can see your core dump will be a limited (small) size.

limit
cputime         unlimited
filesize        unlimited
datasize        unlimited
stacksize       8192 kbytes
coredumpsize    256 kbytes
descriptors     256
memorysize      unlimited

Now the largest size file "core" can be is limited to 256 kbytes. Something that will not put you over quota.

You can also put this command in your shell startup file, so that it is set every time you login, and thus you don't have to type it at the prompt each session.

The opposite of this command is "unlimit".

For more flags and choices, see the documentation at: man limit, man ulimit

Last Modified: Dec 19, 2016 11:12 am US/Eastern
Created: Sep 29, 2008 5:04 pm GMT-4 by admin
JumpURL: