Linux core File Settings

Source: Internet
Author: User

Linux core File Settings 1. A brief introduction to the core file when a program crashes, it generally generates a core file under the specified directory. The core file is only a memory image (with debugging information added) and is mainly used for debugging. 2. to enable or disable the generation of core files, run the following command to prevent the system from generating core files: ulimit-c 0 to check whether the option for generating core files is Enabled: ulimit-a this command will display all user customization, where option-a represents "all ". You can also modify the system file to adjust the core option. in/etc/profile, this statement is usually used to prohibit the generation of core files. This setting is generally reasonable: # No core files by default ulimit-S-c 0>/dev/null 2> & 1 but sometimes for debugging problems during development, you still need to enable the settings generated by the core file in a specific user environment ~ /. Adding ulimit-c unlimited to bash_profile allows specific users to generate core files. If ulimit-c 0 is used, core files are not allowed, ulimit-c 1024 limits the size of the generated core file to kb. set the Core Dump file directory and naming rules for core Dump./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, if it is added, the file content is 1; otherwise, the format is 0/proc/sys/kernel/core_pattern. You can set the location or file name of the formatted core file, for example, if the original file content is core-% e, you can modify it as follows: echo "/corefile/core-% e-% p-% t">/proc/sys/kernel/core_pattern controls the generated core files to be stored in the/corefile directory, production The generated file name is core-command name-pid-timestamp. The following lists the parameters: % p-insert pid into filename add pid % u-insert current uid into filename add current uid % g-insert current gid into filename add current gid % s-insert signal that caused the coredump add into the filename to generate the core signal % t-insert UNIX time that the coredump occurred into filename unix time when adding the core file to generate % h-insert hostname where the coredump happened into filename add host name % e-insert c Oredumping executable name into filename add command name 4. use the core file and enter gdb-c core in the directory where the core file is located. It starts the GNU Debugger to debug the core file and displays the program name that generates the core file, abort the program signal. If you already know which program generates the core file, for example, if MyServer crashes to generate core.12345, use this command for debugging: gdb-c core MyServer: how to learn how to use gdb? 5. run the command kill-s SIGSEGV $6 to generate a core file in a small way. why sometimes the program is Down, but the Core file is not generated. In Linux, some settings indicate resources available to the shell and to processes. You can use # ulimit-a to view these settings. (Ulimit is bash built-in Command) -a All current limits are reported-c The maximum size of core files created-d The maximum size of a process has encrypted data segment-e The maximum scheduling priority ("nice ") -f The maximum size of files written by the shell and its children-I The maximum number of pending signals-l The maximum size that may be locked into memory-m The maximum resident set size (has no Effect on Linux)-n The maximum number of open file descriptors (most systems do not allow this value to be set) -p The pipe size in 512-byte blocks (this may not be set) -q The maximum number of bytes in POSIX message queues-r The maximum real-time scheduling priority-s The maximum stack size-t The maximum amount of cpu time in seconds-u The maximum number of processes available to a single u Ser-v The maximum amount of virtual memory available to the shell-x The maximum number of file locks can be seen from here, if-c is to show: core file size (blocks, -c) If the value is 0, the core file cannot be generated. Therefore, you can use # ulimit-c 1024 or # ulimit-c unlimited to enable core files. If the program generates a Core file when an error occurs, Segmentation fault (core dumped) is displayed ). 7. core Dump core Dump file directory and naming rules:/proc/sys/kernel/core_uses_pid can be used to control whether pid is added as an extension to the file name of the generated Core file, if the file is added, the file content is 1; otherwise, the file content is 0.

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.