Name core files by program and PID with %e and %p in core_pattern
Name Linux core files after the program and PID with kernel.core_pattern and the %e and %p specifiers, so crashes do not overwrite each other.
Every crash writes a file called core in the crashing process's working directory, and the second crash overwrites the first. kernel.core_pattern is the template the kernel uses for that name, and %e and %p put the program name and the PID in it, so each crash gets its own file.
sudo sysctl -w kernel.core_pattern=/var/cores/core.%e.%p
mkdir -p /var/cores && chmod 1777 /var/cores
ulimit -c unlimited
sleep 100 &
kill -SEGV $!
ls /var/corescore.sleep.4242The PID will differ. Other specifiers include %t for the time of the dump in seconds since the epoch, %h for the hostname and %s for the signal number, all listed in core(5) for Linux 6.12. Two limits catch people. %e is the process's comm value, which is cut to 15 characters. And the directory must be writable by the crashing process, since the kernel writes the file as that user, or nothing is written and nothing says so. If the pattern starts with a pipe character, the kernel runs a program instead and gives it the dump on stdin, which is how systemd-coredump works, so check cat /proc/sys/kernel/core_pattern first on a systemd machine.