Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing location of core dump

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?

like image 791
rogue_knight9 Avatar asked Apr 16 '13 22:04

rogue_knight9


People also ask

Where are core dumps stored Mac?

Core dumps are located in the /cores/ directory for all versions. MacOS 10.4 and Higher: Core dumps are disabled by default. To enable core dumps on a MacOS machine of version 10.4 and higher create the file, /etc/launchd.

Where are core dumps stored RHEL?

Red Hat Enterprise Linux 6/7/8 has a service called abrt , which automatically collects the core dump files on the server and stores them inside the /var/spool/abrt .

Where is my core dump Ubuntu?

In Ubuntu the core dumps are handled by Apport and can be located in /var/crash/. But it is disabled by default in stable releases.

Where are core dumps stored?

By default, all core dumps are stored in /var/lib/systemd/coredump (due to Storage=external ) and they are compressed with zstd (due to Compress=yes ). Additionally, various size limits for the storage can be configured. Note: The default value for kernel. core_pattern is set in /usr/lib/sysctl.


2 Answers

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]

like image 164
mata Avatar answered Oct 05 '22 01:10

mata


Before following the instructions in the accepted answer, it could be good idea to check the contents of /proc/sys/kernel/core_pattern to see if the Redhat abrt system is in use.

-> cat /proc/sys/kernel/core_pattern |/usr/libexec/abrt-hook-ccpp %s %c %p %u %g %t e 

If that is in use, then you already have a pretty extensive scheme for managing core files that you would want to understand before you override it.

In a nutshell, abrt:

  1. puts the core files here: /var/spool/abrt/
  2. has a gui that is started with the command abrt-gui
  3. augments the corefile with additional information about the failed process.
  4. is configure with this file: /etc/abrt/abrt-action-save-package-data.conf

One common stumbling block with using it is to change this line in the config file:

ProcessUnpackaged = no 

Change that to yes to capture core files from your homebrew processes, otherwise it will only capture corefiles from programs installed by the package manager.

[EDIT to answer how to use coredump] To examine a core dump I do this:

cd /var/spool/abrt/XXXXXXX gdb $(cat executable) coredump 

There might be a better way to so that, but gdb has served me well so I have not looked for other ways. Just replace XXXXXXX with the folder that contains your coredump file. The gdb command is cut and paste ready.

References:

Redhat Book

CentOS Forum

like image 22
Be Kind To New Users Avatar answered Oct 05 '22 01:10

Be Kind To New Users