Managing core files

If you have grown tired of having core files laying around all over the place you can manage them using coreadm command. You can set up system to save core files to a specific location.

First, here are the default core settings on a Solaris box:

bash-3.00# coreadm
global core file pattern:
global core file content: default
init core file pattern: core
init core file content: default
global core dumps: disabled
per-process core dumps: enabled
global setid core dumps: disabled
per-process setid core dumps: disabled
global core dump logging: disabled

Now, let’s configure the system to save init core files in /var/crash/cores in format EUID.execName.core:

bash-3.00# coreadm -i /var/crash/cores/%u.%f.core
bash-3.00# coreadm
global core file pattern:
global core file content: default
init core file pattern: /var/crash/cores/%u.%f.core
init core file content: default
global core dumps: disabled
per-process core dumps: enabled
global setid core dumps: disabled
per-process setid core dumps: disabled
global core dump logging: disabled

To test our setup, we can use gcore command.

bash-3.00# gcore -p 741
gcore: /var/crash/cores/0.bash.core dumped
bash-3.00# ls /var/crash/cores
0.bash.core          hsperfdata_noaccess  hsperfdata_root
bash-3.00#

Above, we generated core file for bash process with PID 741 run under effective UID 0. This should make the system tidier as far as core files are concerned.