One Linux command per day (1): Top command

Source: Internet
Author: User
Tags set time

The top command is a common performance analysis tool under Linux that shows the resource usage of individual processes in the system in real time, similar to the Task Manager for Windows. Here is a detailed description of how it is used. Top is a dynamic display process where 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 will display the most "sensitive" CPU in the system. Task List. This command can be used by CPU. Memory usage and execution time to sort tasks, 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 Displays the complete ruling 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

Output:

[email protected] ~]# toptop-14:06:23 up, 16:44,  2 users, load average:1.25, 1.32, 1.35Tasks:206 Total, 1 running, 205 sleeping, 0 stopped, 0Zombiecpu (s):5.9%us, 3.4%sy, 0.0%ni, 90.4%id, 0.0%wa, 0.0%hi, 0.2%si, 0%stmem:32949016k Total, 14411180k used, 18537836k free, 169884k buffersswap:32764556k total, 0k used, 32764 556k free, 3612636k cached PID USER PR NI VIRT RES SHR S%CPU%MEM time+COMMAND28894 Root 0 1501m 405m 10m S 52.2 1.3 2,534:16Java18249 Root 0 3201m 1.9g 11m S 35.9 6.0 569:39.41Java2808 Root 0 3333m 1.0g 11m S 24.3 3.1 526:51.85Java25668 Root 0 3180m 704m 11m S 14.0 2.2 360:44.53Java574 Root 0 3168m 611m 10m S 12.6 1.9 556:59.63Java1599 Root 0 3237m 1.9g 11m S 12.3 6.2 262:01.14Java1008 Root 0 3147m 842m 10m S 0.3 2.6 4:31.08Java13823 Root 0 3031m 2.1g 10m S 0.3 6.8 176:57.34Java28218 Root 0 12760 1168 808 R 0.3 0.0 0:01.43Top29062 Root 0 1241m 227m 10m S 0.3 0.7 2:07.32Java1 root 0 10368 684 572 S 0.0 0.0 1:30.85Init2 root RT-5 0 0 0 S 0.0 0.0 0:01.01 migration/0                                                                3 Root 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0                                                                 4 root RT-5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0                                                                5 root RT-5 0 0 0 S 0.0 0.0 0:00.80 MIGRATION/1                                                                6 Root 0 0 0 S 0.0 0.0 0:00.00 KSOFTIRQD/1                                                                 7 Root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/1 8 root RT-5 0 0 0 S 0.0 0.0 0:20.59 Migra TION/2 9 Root 0 0 0 S 0.0 0.0 0:0        0.09 KSOFTIRQD/2                                                       Root RT-5 0 0 0 S 0.0 0.0 0:00.00 watchdog/  2 root RT-5 0 0 0 S 0.0 0.0 0:23.66    MIGRATION/3 Root 0 0 0 S 0.0 0.0   0:00.03 KSOFTIRQD/3 root RT-5 0 0 0 S    0.0 0.0 0:00.00 WATCHDOG/3 root RT-5 0  0 0 S 0.0 0.0 0:20.29 MIGRATION/4 Root 34       0 0 0 S 0.0 0.0 0:00.07 KSOFTIRQD/4 Root                                                                RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/4  Root RT-5   0 0 0 S 0.0 0.0 0:23.07 MIGRATION/5 Root 0 0 0 S 0.0 0.0 0:00.07 KSOFTIRQD/5 1                                                                9 Root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/5                                                               Root RT-5 0 0 0 S 0.0 0.0 0:17.16 MIGRATION/6                                                               Root 0 0 0 S 0.0 0.0 0:00.05 KSOFTIRQD/6                                                                Root RT-5 0 0 0 S 0.0 0.0 0:00.00 WATCHDOG/6 Root RT-5 0 0 0 S 0.0 0.0 0:58.28 MIGRATION/7

Description

Statistical information Area:

The first five elements are the statistical information area of the current system situation as a whole. Let's look at the specific meaning of each line of information.

The first line, the task queue information, and the execution results of the uptime command, specify the following parameters:

14:06:23-Current system time

Up to 70 days, 16:44-the system has been running for 16 hours and 44 minutes (during which the system has not restarted the Yo!). )

2 users-currently has 2 users logged into the system

The three numbers behind the 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 as follows:

The system now has 206 processes, of which there are 1 running, 205 in hibernation (sleep), 0 in the stoped state, and 0 in the zombie State (zombie).

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

5.9%us-the percentage of CPU occupied by the user space.

3.4% sy-The percentage of CPU consumed by the kernel space.

0.0% ni-The percentage of CPU that has changed the priority of the process

90.4% id-Idle CPU percentage

0.0% Wa-io waiting for CPU percentage

0.0% hi-Hard Interrupt (Hardware IRQ)% of CPU occupied

0.2% si-Soft Interrupt (software interrupts)% of CPU occupied

Note: In this case the CPU usage ratio differs from the Windows concept, and you need to understand the Linux system user space and kernel space knowledge!

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

32949016k total-Total Physical memory (32GB)

14411180k used-Total Memory in use (14GB)

18537836k free-Total free memory (18GB)

169884k buffers-Cache Memory (169M)

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

32764556k total-Swap Area total (32GB)

Total swap area used by 0k used-(0K)

32764556k free-Total Idle swap area (32GB)

3612636k cached-Buffer Swap area total (3.6GB)

Line six, blank line.

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

pid-Process ID

user-Process Owner

pr-Process Priority

The Ni-nice value. Negative values indicate high priority, positive values indicate low priority

The total amount of virtual memory used by the virt-process, in kilobytes. Virt=swap+res

The size, in kilobytes, of the physical memory used by the res-process and not 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-percentage of CPU time that was last updated to current

Percentage of physical memory used by the%mem-process

Total CPU time used by the time+-process, Unit 1/100 sec

command-Process Name (command name/command line)

One Linux command per day (1): 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.