One Linux command per day (--top) command

Source: Internet
Author: User
Tags set time cpu usage

Today to the leader e-mail, my side although the display sent to, but his side has not received, the result I thought I sent, he has been there for the results. So, in the future to send a message or QQ or something like that.

The top command is a common performance analysis tool under Linux that shows the resource usage of each process in real time, similar to the Task Manager of Windows. Here is a detailed description of how it is used. Top is a dynamic display process in which the current state can be refreshed continuously with the user key. If the command is executed in the foreground, it will monopolize the foreground until the user terminates the program. More accurately, the top command provides real-time status monitoring of the system's processor. It displays a list of the most CPU-sensitive tasks in the system, which can sort tasks by CPU, memory usage, and execution time, and many of the features of the command can be set through interactive commands or in personal customization files.

1. Command format:

Top [parameters]

2. Command function:

Displays information about the processes currently being executed by the system, including process IDs, memory usage, CPU utilization, etc.

3. Command parameters:

-B Batch Processing

-C Display full command

-I ignores the failure process

-S Secret mode

-S cumulative mode

-i< time > Set time interval

-u< User name > Specify user name

-p< Process number > Specify process

-n< number of times > cycle display

4. Usage examples:

Example 1: Displaying process information

Command: Top

Top command details: The first five elements is the current system of the overall statistical information to go. Let's look at the specific meaning of each line of information.

The first line, the task queue information, the execution result of the pass uptime command, the specific parameters are described as follows:

14:00:00---The current system time up 10000 days, the---system has been running for 10,000 day and 12 hours (during this period the system has not been restarted Oh!). )

2 users-There are currently 2 user login systems

The three numbers behind load average:1.15, 1.42, 1.44--load average are 1-minute, 5-minute, 15-minute loads respectively.

The load average data is the number of active processes that are checked every 5 seconds and then calculated by a particular algorithm. If this number is divided by the number of logical CPUs, the result above 5 indicates that the system is overloaded.

The second line, Tasks-task (process), specific information is described as follows:

The system now has a total of 187 processes, of which 2 are running, 186 are in hibernation, 0 are in a stopped state, and there are 0 zombie states.

The third line, CPU status information, the specific properties are described as follows:

5.9%-Percentage of CPU occupied by user space

3.4% SY--Percentage of CPU consumed by kernel space

0.0% ni-Change the priority amount the percentage of CPU that the process consumes

90.4% ID--Percentage of idle CPU

0.0% wa--io% waiting to occupy CPU

0.0% Hi--Hard interrupt (hardware IRQ)% of CPU occupied

0.1% Si--Soft interrupt (software interrupts)% of CPU occupied

Note: In this case, the CPU usage ratio differs from the Windows concept and requires an understanding of the Linux system user space and kernel space.

Line four, the memory state, the specific information is as follows:

1234456k Total--Overall physical memory

1234456k used--total amount of memory in use

1234456K Free--Total idle memory

1234456k buffers--The amount of memory in the cache

Line five, swap swap partition information, specific information as follows:

123344k Total-Swap area totals

Ok used---The total number of swap areas used

123344k Free--Total idle swap area

123344k Cached--buffer swap area total

Note:

The total amount of memory used in row four refers to the amount of memory that is now controlled by the system kernel, and the total amount of free memory that the kernel has not included in its management scope. The memory that is included in kernel management is not always in use, but also includes the memory that has been used in the past that can now be reused, and the kernel does not return these reusable memory to free, so there is less memory on Linux, but don't worry about it.

If you are in the habit of calculating the number of available memory, here is an approximate formula: The fourth line of Free + fourth row of buffers + fifth row of cached, press this formula this server's available memory 1 +2+3.

For memory monitoring, in the top we have to monitor the fifth line swap partition used, if this value is constantly changing, indicating that the kernel is constantly in memory and swap data exchange, which is really not enough memory.

Line six, blank line.

Line seventh below: status monitoring of each process, project column information is described as follows:

PID--Process ID

USER--Process Owner

PR--Process priority

NI--Nice value

VIRT-Total amount of virtual memory used by the process, Unit kb,virt=swap=res

RES-The amount of physical memory, in kilobytes, that the process uses and has not been swapped out. Res=code+data

SHR--Shared memory size, in kilobytes

S--process state. d= non-disruptive sleep status r= run s= sleep t= track/stop z= zombie Process

%CPU-The percentage of CPU time occupied last updated to current

%MEM--Percentage of physical memory used by the process

Time--total CPU times used by the process, units 1/100 seconds

command--process name (name/command line)

Other tips for use:

1. Multi-u multi-core CPU monitoring

In the top basic view, press the keypad number 1 to monitor the status of each logical CPU.

2. Highlight the current running process

Tap Keyboard B,

3. Process field Sorting

By default, when you go to top, the processes are sorted by CPU consumption, and an X can highlight the dosage, but I tried it without effect.

4. Press the shift +> once

Example 2: Show full command

Command: Top-c

Example 3: Displaying program information in batch mode

Command: Top-b

Example 4: Displaying program information in cumulative mode

Command: Top-s

Example 5: Set Information update times

Command: Top-n 2

Example 6: Set Information update time

Command: Top-d 3 indicates an update period of 3 seconds

Example 7: Displaying the specified process information

Command: Top-p 123

5.top Interactive Commands

Some of the interactive commands that you can use during the top command execution. These commands are single-letter, and some of these commands may be masked if the S option is used on the command line.

H Display the help screen and give some brief command summary instructions

K Terminating a process

I ignore idle and zombie processes, which is a switch-type command.

Q Exit Program

R reschedule a process's priority level

S Switch to cumulative mode

s change the delay time between two refreshes (in units of s), if there are decimals, converted into MS, enter 0 value then the system will be constantly refreshed, the default value is 5s.

F or F Add or remove items from the current display

0 or 0 change the order in which items are displayed

L Toggle display of average load and start-up time information

M Toggle Display Memory Information

T toggle display of process and CPU status information

C Toggle Display command name and full command line

M sort based on resident memory size

P Sort by percentage of CPU usage

T Sort by Time/cumulative time

W writes the current setting to ~/. In the TOPRC file

 

   

    

    

  

One Linux command per day (--top) command

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.