34. Linux Shell, common function strace

Source: Internet
Author: User

1. Description

Strace-trace system CILS and Signals

2. Option

1) strace-p pid tracks a background process

2) strace-O filename outputs the trace result to the file

3) strace-T records the time spent on each system call. You can see which system call takes a long time.

Reference

4) strace-T (or-TT) records the time when each system call occurred (in the format of hour, minute, and second)

5) When strace-s 1024 displays system call parameters, the length of the string is displayed. The default value is 32. If the string parameters are long, a lot of information cannot be displayed.

6) strace-e trace = nanosleep only records relevant system call Information.

-E trace = network // only records system calls related to network APIs

-E trace = file // only records system calls involving file names

-E trace = DESC // only records system calls involving file handles

= All // All system calls

= Execve

-E trace = set: only tracks system calls in the specified set. For example,-e trace = open, close,

Rean and write indicate that only the four system calls are tracked. The default value is set = All.

Others include process, IPC, and signal.

7)-f: in addition to tracking the current process, it also traces its sub-processes.

8)-u username -- Run Command as Username Handling setuid and/or setgid

3. Example

Strace-O output.txt-T-TT-e trace = All-P 28979 // trace all system calls of the 28979 process (in the-e worker file.

4. strace

This parameter is applicable to processexp.exe in windows.

Monitor System calls

2) similar to the depand tool in Windows

CheckProgram. It is more powerful than LDD in Linux.

5. the Linux kernel creates a directory named "/PID" for each process in/proc/to save information about the process, the sub-directory FD stores the FD of all files opened by the process.

Reference

[1]Http://blog.csdn.net/zdl1016/article/details/6359598

[2] Three excellent cases are provided for strace.

Http://www.linuxsense.org/archives/413.html

[3] made a detailed list of commands and provided instances.

Http://www.jb51.net/ OS /RedHat/1156.html

[4] A unique explanation and translation of parameters

Http://hi.baidu.com/edeed/blog/item/e3eba40f227021e6ab6457bf.html

[5]Http://blogimg.chinaunix.net/blog/upfile/070331234055.pdf

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.