Use the top command in linux to view the system running status and process running status

Source: Internet
Author: User
In linux, you can run the top command to check the system running status and process running status. you can run the man command to check the top Manual. the top command is interpreted as displayLinuxtasks. you have seen another explanation: displaytopCPUprocesses, I think this is quite appropriate, because the top command will automatically overwrite the processes that consume a lot of data.

In linux, you can run the top command to check the system running status and process running status. you can run the man command to check the top Manual. the top command explains display Linux tasks, I have seen another explanation in the past: display top CPU processes, which I think is quite appropriate, because the top command will automatically forward high-consumption processes.

1. Command description

Top parameters
  • -H: help indicates the meaning of help.
  • -V: version indicates the version, which is the same as-h.
  • -U: displays the process of the specified user, for example, top-u root.
  • -P: pid displays the specified process, for example, top-p 1
  • -N: after the number is set to top, the top will be refreshed regularly. this value is set to refresh several times.
  • -D: after delay is set to top, the top will be refreshed regularly. this value is set to a few seconds to refresh.
  • -B: Batch mode. The top Refresh status is refreshed on the original data by default. after this parameter is used, data is displayed on a screen. Combined with the redirection function and scheduled tasks, this parameter is very useful when recording the server running status.

The preceding parameters are provided when you enter the command. during top running, you can enter shortcut keys to adjust the display content.

Shortcut keys for running some commands:

  • Q: quit the program.
  • M: Memory is sorted by Memory usage
  • P: CPU is sorted by cpu usage
  • K: kill the process that kills the PID. if you do not enter the PID, press enter to exit.
  • 1: displays the status of each CPU core.
  • H or? : Help to view more shortcut keys
  • F: fields view the meaning of the process header field

2. Command Test

top

Top Command Test

The first line is described as follows:

Top-: Current system time

Up: the continuous running time of the server. I have seen a server running continuously for more than one year. The linux server is still very stable.

User: Number of users currently logged on to the system

Load average, the cpu usage is usually below 1, indicating that the cpu usage is not high. If the cpu usage is above 5, the cpu will be in a high load status and will easily go down. Once a project went live and worked overtime at night to observe the server status. this value was kept around 72 for a long time. because the server had eight cores, the value of each core was 9, and then the server went down.

The second line shows the number of tasks. zombie should note that this indicates a zombie process. when a zombie process occurs, pay attention to how the zombie process is generated. If the cause is not found, it may appear again even if it is killed.

The third line indicates the cpu running Status. press 1 to display the running status of each core.

The fourth line indicates the memory usage.

The fifth line indicates the usage of swap space swap.

The following shows the running status of the process. The meaning of each header is as follows:

  • PID: Process ID
  • USER: the USER to which the process belongs.
  • PR/NI: Priority/Nice value process execution Priority
  • VIRT: Virtual Image (kb) Total Virtual memory usage
  • RES: Resident size (kb) Resident memory
  • SHR: Shared Mem size (kb) Shared memory
  • S: Process Status
  • % CPU: cpu usage
  • % MEM: memory usage
  • TIME +: total cpu usage TIME when the process starts running
  • COMMAND: The COMMAND run by the process.

In the top state, press f to view the description of the header field.

3. common commands:

top -b -n 60 -d 60 > /home/cpu.txt

This command saves the running status of the server to a text file every 60 seconds. it runs 60 times in total and saves the running status of the server for one hour. This command can be used to record the server load during busy hours. for example, it can be set between PM and PM so that the server status can be adjusted, instead of waiting for the server to fail. The parameters in the preceding command can be modified as needed. Finally, you don't have to work overtime to observe the server.

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.