Changing location of core dump

rogue_knight9 picture rogue_knight9 · Apr 17, 2013 · Viewed 95.4k times · Source

I want to change the default location of core dump files so that every time a core dump is generated ,it goes to that directory.Also, is it possible to save the dump file by the name of the crashed file in this location?

Answer

mata picture mata · Apr 17, 2013

Yes, it is. You can change /proc/sys/kernel/core_pattern to define the pathname used to generate the corefile. For more, see man core

example:

echo '/tmp/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern    # `tee' instead of > so that
                                                                   # opening happens in the
                                                                   # elevated process

would cause all future core dumps to be generated in /tmp and be named core_[program].[pid]