Core dump in Linux "turn" on the use tutorial

Source: Internet
Author: User

Transferred from: http://www.111cn.net/sys/linux/67291.htm

First, what is Coredump

We often hear people say that the program core dropped, need to locate the solution, most of this refers to the corresponding program due to various anomalies or bugs in the process of abnormal exit or abort, and under certain conditions (why do we need to meet certain conditions?) The following analysis will produce a file called core.

Typically, the core file contains the program runtime memory, register state, stack pointers, memory management information and various function call stack information, we can understand that the program is the current state store to generate the first file, many of the program error will produce a core file, Through the tool analysis of this file, we can locate the program when the exception exits the corresponding stack call information, identify the problem and timely resolution.

Second, cored dump open

Perform a ulimit–c check to see if core dump is turned on, and if the result is 0, it is considered that the core dump file is not enabled for the build and needs to be opened. There are three ways to open core dump, one that is temporarily enabled and two that are permanently enabled.

Temporarily enabled

Method 1 (Ulimit command method)

Execute the following command:

Ulimit-c 1024
Or
Ulimit-c Unlimited
In the above example, the first is to limit the core dump file size not more than 1024K, the latter is not limited to the size of the core dump file, now the program occupies a fierce memory, the previous write C program needs to calculate the memory of the era has passed. If there is no limit, maybe a core file, a few g will go out. So it's best to limit that in small.

Two ways to permanently enable:

Method Two (Profile modification method)

Open the/etc/profile file and add the following and make it effective:

Ulimit-s-C Unlimited >/dev/null 2>&1
Note: If the file has a ulimit-s-C 0 >/dev/null 2>&1 line, you need to comment out the line first. After the setup is complete, it takes effect by executing source/etc/profile.

Method Three (Modify the/etc/security/limits.conf file)

Locate the "* Soft core 0" line and modify it to the following:

This method can open core dump for the specified user or user group, as set to "* Soft core 10485760", i.e. the core dump file size is 10G.

It is important to note that the settings in this and method two are conflicting, and in one of these settings, the third method is recommended, because it can be set up for different users and groups and more flexible.

Note: The above three method settings do not need to restart the machine, need to do is to exit the terminal and reconnect, restart the need for core dump program.

Third, modify the core dump file format

Customize the path of the core, name format, by modifying the following two configurations:

Again the first sentence configuration,/proc/sys/kernel/core_uses_pid if the content of this file is configured to 1, the final generated core dump file name will still be added to the process ID even if%p is not set in Core_pattern.

It is important to note that since the configuration under/proc is in immediate effect, the previous configuration will be invalidated after reboot. So you can add the following configuration to the/etc/sysctl.conf file, as follows:

After saving, the execution sysctl-p takes effect.

Note: It is important to note that the Corefiles configured above must have write permissions, otherwise the core dump file cannot be generated and can be created with the following command:

The code is as follows
1 User Soft Core 1024
or @group soft core 1024
The code is as follows
1 Echo 1 >/proc/sys/kernel/core_uses_pid
echo '/corefiles/core-%e-%p-%t ' >/proc/sys/kernel/core_pattern
Here first the configuration instructions for the next parameter:
2 Percent of a single% character
Process ID of the%p dump process
The actual user ID of the%u dump process
%g The actual group ID of the dump process
%s causes the signal for this core dump
%t Core Dump time (number of seconds from January 1, 1970)
%H Host Name
%e program file name
The code is as follows
1 Kernel.core_uses_pid = 1
Kernel.core_pattern =/corefiles/core-%e-%p-%t
The code is as follows
1 # Mkdir/corefiles
# chmod 777/corefiles

Core dump in Linux "turn" on the use tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.