Linux Core File Settings

Source: Internet
Author: User



1.
Ulimit-C view the Core File Size configured by the current system
Ulimit-C unlimited: Change the core file size to unlimited.


2.
Change/proc/sys/kernel/core_uses_pid to 1 and set it to the file name that can control the generated core file.
To modify a file, you must use echo "1"
>/Proc/sys/kernel/core_uses_pid

3.
/Proc/sys/kernel/core_pattern can control the core file storage location and file name format
We recommend/home/CORE. % P. % u. % E _ % T. It is best to set the permission for this directory to 777.

4.
/Proc/sys/fs/suid_dumpable some programs will switch users. At that time, the core file cannot be generated normally. In this case, set it to 1
To modify a file, you must use echo "1"
> // Put proc/sys/fs/suid_dumpable

After modifying the file, restart the program. If the program is pulled from another one, restart the program in the following order: 1. Pull the program; 2. Pull the program.

In the user's ~ /. Add ulimit to the bash_profile.
-C unlimited to allow specific users to generate core files
You can set the Core File Size in ulimit-C 1024...
In addition, for the naming rules of the generated core files, files in the following two proc file systems will have an impact on them:
1./proc/sys/kernel/core_uses_pid can be used to control whether PID is added to the file name of the generated core file as an extension.
2./proc/sys/kernel/core_pattern can be used to set the location or file name of the formatted core file,
For example,/corefile/Core-% E-% P-% T will control the generated core file to be stored in the/corefile directory, the generated file name is core-command name-PID-timestamp.

/Home/enip/CORE/Core

/Corefiles/CORE. % P. % E



In Linux, a core file is usually generated when the process exits abnormally. This file is a memory dump file when the process crashes, also known as core dump.

View Linux script Parsing Method: Echo $0

1. Check whether the core is enabled

Log On With see/See

CSH: limit; coredumpsize = 0, indicating that the core is not enabled; otherwise, the core is enabled.



Bash: ulimit-A; pay attention to the red part. If the value is 0, the core is not opened; otherwise, the core is opened.



2. Enable core and set the size.

If it is not enabled, enable it permanently. Log On As A root/user, VI/etc/security/limits. conf, and pay attention to the soft part in red



Temporarily specify the size to log on as the SEE/See user,

CSH: Limit coredumpsize 4096000

Bash: ulimit-C 4096000 is smaller than the size set in/etc/security/limits. conf

Note: These parameters are temporary. Once the active window is closed and opened again, the core size is invalid.

 

3. Core path Configuration

Note: The specified core path has the write permission.

Log On As the SEE/See user,/sbin/sysctl-A | grep core, and view the path of the current core file.

Check the two configuration values kernel. core_pattern and kernel. core_uses_pid.

Kernel. core_pattern: Core File Path

Kernel. core_uses_pid: generate the core file, with the suffix PID 1: belt; 0: No

Temporary path modification (root permission required)

/Sbin/sysctl-W kernel. core_pattern =/CORE. % E. % P

/Sbin/sysctl-W kernel. core_uses_pid = 0


% P-insert PID into filename --- display process number


% U-insert current uid into filename
--- User ID

% G-insert current GID into filename
--- Group ID

% S-insert signal that caused the coredump into the filename
--- Add the signal that causes the core to be generated

% T-insert UNIX time that the coredump occurred into filename
--- Time

% H-insert hostname where the coredump happened into filename
--- Host Name

% E-insert coredumping executable name into filename --- name


Modify the path permanently (root permission is required, and server restart will take effect ):


Modify/etc/sysctl. conf and add two lines:

Kernel. core_pattern =
/CORE. % E. % P

Kernel. core_uses_pid =
0

Settings take effect
Sysctl-P/etc/sysctl. conf

4. Generate core (used for self-testing)

To see/See users, KSh; kill-11 $


5. Positioning and analysis core


GDB container core file

Then: BT


6. Disable Core

Temporarily close:

CSH: Limit coredumpsize 0

Bash: ulimit-C 0

Note: These parameters are temporary. Once the active window is closed and opened again, the core size is invalid.

Permanently close:





1.
Ulimit-C view the Core File Size configured by the current system
Ulimit-C unlimited: Change the core file size to unlimited.


2.
Change/proc/sys/kernel/core_uses_pid to 1 and set it to the file name that can control the generated core file.
To modify a file, you must use echo "1"
>/Proc/sys/kernel/core_uses_pid

3.
/Proc/sys/kernel/core_pattern can control the core file storage location and file name format
We recommend/home/CORE. % P. % u. % E _ % T. It is best to set the permission for this directory to 777.

4.
/Proc/sys/fs/suid_dumpable some programs will switch users. At that time, the core file cannot be generated normally. In this case, set it to 1
To modify a file, you must use echo "1"
> // Put proc/sys/fs/suid_dumpable

After modifying the file, restart the program. If the program is pulled from another one, restart the program in the following order: 1. Pull the program; 2. Pull the program.

In the user's ~ /. Add ulimit to the bash_profile.
-C unlimited to allow specific users to generate core files
You can set the Core File Size in ulimit-C 1024...
In addition, for the naming rules of the generated core files, files in the following two proc file systems will have an impact on them:
1./proc/sys/kernel/core_uses_pid can be used to control whether PID is added to the file name of the generated core file as an extension.
2./proc/sys/kernel/core_pattern can be used to set the location or file name of the formatted core file,
For example,/corefile/Core-% E-% P-% T will control the generated core file to be stored in the/corefile directory, the generated file name is core-command name-PID-timestamp.

/Home/enip/CORE/Core

/Corefiles/CORE. % P. % E



In Linux, a core file is usually generated when the process exits abnormally. This file is a memory dump file when the process crashes, also known as core dump.

View Linux script Parsing Method: Echo $0

1. Check whether the core is enabled

Log On With see/See

CSH: limit; coredumpsize = 0, indicating that the core is not enabled; otherwise, the core is enabled.



Bash: ulimit-A; pay attention to the red part. If the value is 0, the core is not opened; otherwise, the core is opened.



2. Enable core and set the size.

If it is not enabled, enable it permanently. Log On As A roouser, VI/etc/security/limits. conf, and pay attention to the soft part in red



Temporarily specify the size to log on as the SEE/See user,

CSH: Limit coredumpsize 4096000

Bash: ulimit-C 4096000 is smaller than the size set in/etc/security/limits. conf

Note: These parameters are temporary. Once the active window is closed and opened again, the core size is invalid.

 

3. Core path Configuration

Note: The specified core path has the write permission.

Log On As the SEE/See user,/sbin/sysctl-A | grep core, and view the path of the current core file.

Check the two configuration values kernel. core_pattern and kernel. core_uses_pid.

Kernel. core_pattern: Core File Path

Kernel. core_uses_pid: generate the core file, with the suffix PID 1: belt; 0: No

Temporary path modification (root permission required)

/Sbin/sysctl-W kernel. core_pattern =/CORE. % E. % P

/Sbin/sysctl-W kernel. core_uses_pid = 0


% P-insert PID into filename --- display process number


% U-insert current uid into filename
--- User ID

% G-insert current GID into filename
--- Group ID

% S-insert signal that caused the coredump into the filename
--- Add the signal that causes the core to be generated

% T-insert UNIX time that the coredump occurred into filename
--- Time

% H-insert hostname where the coredump happened into filename
--- Host Name

% E-insert coredumping executable name into filename --- name


Modify the path permanently (root permission is required, and server restart will take effect ):


Modify/etc/sysctl. conf and add two lines:

Kernel. core_pattern =
/CORE. % E. % P

Kernel. core_uses_pid =
0

Settings take effect
Sysctl-P/etc/sysctl. conf

4. Generate core (used for self-testing)

To see/See users, KSh; kill-11 $


5. Positioning and analysis core


GDB container core file

Then: BT


6. Disable Core

Temporarily close:

CSH: Limit coredumpsize 0

Bash: ulimit-C 0

Note: These parameters are temporary. Once the active window is closed and opened again, the core size is invalid.

Permanently close:




Related Article

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.