Organizing core dumps

Tired of looking for core files in your whole $HOME (because apps do chdir, and cores are by default in $PWD)?

mkdir /cores; chmod go+w /cores; echo “/cores/%e.%p.core” > /proc/sys/kernel/core_pattern

And voilà, you’ll find your cores easily in /cores. Much easier than find ~ -mtime 0 -name ‘core*’ !

6 Responses to “Organizing core dumps”

  1. Myles Green Says:

    Wow Colin, you rock!! Awesome tip, thank you.

  2. Simon Kågström Says:

    Linux also supports passing a command to pipe the core to as the core_pattern. Quite useful in many situation (think embedded systems) where you can compress the core dump and attach other useful information (as apport is doing).

    // Simon

  3. Myles Green Says:

    That sounds interesting too, could you do an example of that please? Thanks!

  4. Simon Kågström Says:

    You just echo something like

    echo “|/path/to/my/script” > /proc/…/core_pattern

    The apport sources serve as a good reference to what you can do. They read the header of the ELF file to get process ID and some other stuff (if I remember correctly :-)), and then collect interesting infromation from /proc etc. So you can get more information about the crash than *just* the core file.

    In the Apport case, you can also get a popup on the desktop which allows you to send the crash to your distribution provider. Anyway, I think the pipe-in-core-pattern is a very useful addition and allows all sorts of interesting things to be done when core dumps are created.

    // Simon

  5. Myles Green Says:

    That’s very interesting… I guess I know what I’ll be reading through this weekend :-)
    Thanks!

  6. Colin Says:

    Thanks for the additional information, Simon :-)

Leave a Reply

news for few, stuff no-one cares about