How to edit the core dump pattern without disabling apport?

You can edit the apport python file to do this. Changing the location of the core is straight forward: instead of

core_path = os.path.join(cwd, 'core') 

you can put

core_path = os.path.join('my_custom_path, 'core)

the name can also be changed in a similar manner i.e. from:

core_path += '.' + str(pid)

to

core_path += '.' + str(my_custom_name) + '.' + str(pid)

note that if you want to add the binary name to the core file, you will have to pass it to apport using the core_pattern i.e something like

|/usr/share/apport/apport %p %s %c %d %P %e

Notice the %e above which passes the executable name to the apport script

Remember to restart the apport service after making a change in the script


Replying late to OP but maybe this will help someone else.

I was trying to do something similar, enable core dumps on startup using a systemd service (in case settings were changed by another developer/deployment).

I also got stuck with apport overwriting the core_pattern:

kernel.core_pattern = |/usr/share/apport/apport %p %s %c %P

Since I didn't want to disable apport, I was able to bypass the apport path by just triggering my service after apport:

[Unit]
Description=Enable Core Dumps
After=apport

[Service]
ExecStart=/usr/bin/enable_core_dump.sh

[Install]
WantedBy=multi-user.target

Then from the bash script I could change core dump location and naming convention.