You can use ulimit -c 0 to disable core dumps, but that obviously won't remove any core files that are already sitting on your filesystem - and sometimes you have no idea where they might be since different stuff can be running in the background from any directory. These files can be a few gigabytes big sometimes, so you don't want them sitting around wasting space. To find them, use the find command. The simplest way would be to print out a list of all the core files it can find, so that you can go and delete them manually:

$ find . -type f -name core

This can take a while, and even longer if you have some mounted network file systems. So you might want to only check on the same file system, this can be done using the xdev option to find:

$ find . -type f -xdev -name core

If you have a lot of core dumps, and you know that none of the files called core are anything that you actually need to keep, then you can use the exec option to delete them (note: the \; at the end is important):

$ find . -type f -xdev -name core -exec rm -iv {} \;

In the above example I added the -iv flags to rm in case someone copy pasted it without thinking...

Deleting them isn't the only thing you can do though, if you wanted to find out what created them then exec the file command on them:

$ find . -type f -xdev -name core -exec file {} \;

Previous Post Next Post