Hi All
This section will show three different examples of creating core files. All of the examples will use the application top to create core files. The examples will be as follows:
- Create a core file in the default pattern with an appended PID
- Create a core file in a designated directory
- Create a core file using % specifiers
Create a Core File In The Default Pattern With An Appended PID
Complete the following to take a core of the top program in the default pattern with and appended PID (logged in as root):
# ulimit -c unlimited
# echo 1 > /proc/sys/kernel/core_uses_pid
# cat /proc/sys/kernel/core_pattern
core
# top &
[1] 20992
# kill -6 20992
[1]+ Stopped top
# fg %1
top
Aborted (core dumped)
# ls core*
core.20992
Please note that the kill command uses the processes PID and the PID of the process will always be different
Create a Core File In a Designated Directory
Complete the following to take a core of the top program with the core file being saved in a specific directory (logged in as root):
# ulimit -c unlimited
# echo 1 > /proc/sys/kernel/core_uses_pid
# mkdir /corefiles
# chmod 777 /corefiles
# echo /corefiles/core > /proc/sys/kernel/core_pattern
# top &
[1] 20992
# kill -6 20123
[1]+ Stopped top
# fg %1
top
Aborted (core dumped)
# ls /corefiles/core*
core.20123
Please note that the kill command uses the processes PID and the PID of the process will always be different
Create a Core File Using % Specifiers
Complete the following to take a core of the top program using % specifiers (logged in as root):
# ulimit -c unlimited
# echo 1 > /proc/sys/kernel/core_uses_pid
# echo /corefiles/core-%e-%p-%t > /proc/sys/kernel/core_pattern
# top &
[1] 24340
# kill -6 24340
[1]+ Stopped top
# fg %1
top
Aborted (core dumped)
# ls /corefiles/core*
core-top-24340-1129845522
In this example the core file is created in the /corefiles directory. Notice the core filename includes the executable name, PID, and the time of the core. Notice also that the PID wasn't appended to the core filename. The PID is not appended if the %p specifier is used in the filename.