Task Manager under Top Linux

Source: Internet
Author: User

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. 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.

 
 $top top-09:14:56 up, 20:56, 1 user, load average:0.02, 0.04, 0.00 tasks:87 Total, 1 running, sleeping, 0 stopped, 0 zombie Cpu (s): 0.0%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%w A, 0.0%hi, 0.0%si, 0.2%st mem:377672k Total, 322332k used, 55340k free, 32592k buffers swap:397308 K Total, 67192k used, 330116k free, 71900k cached PID USER PR NI VIRT RES SHR S%cpu%MEM time+ CO   Mmand 1 root 0 2856 656 388 s 0.0 0.2 0:49.40 init 2 root 0 0 0 0 S 0.0 0.0     0:00.00 Kthreadd 3 Root 0 0 0 0 S 0.0 0.0 7:15.20 ksoftirqd/0 4 root RT 0 0 0 0 S 0.0 0.0 0:00.00 migration/0 

  • line one
    • 09:14:56: System Current time
    • 264 days, 20:56: How much time has elapsed before the system is booted
    • 1 Users: Current 2 users online
    • load average:0.02, 0.04, 0.00: System 1-minute, 5-minute, 15-minute CPU load information
  • Second line
    • tasks: task;
    • Total: It is well understood that there are currently 87 tasks, that is, 87 processes.
    • 1 Running:1 a process is running
    • Sleeping:86 a process sleep
    • 0 stopped: Number of processes stopped
    • 0 Zombie: Number of zombie processes
  • Third line
    • CPU (s) : Indicates that this line shows CPU overall information
    • 0.0% US: The user-state process consumes CPU time as a percentage, and does not contain the time of the CPU occupied by a task with a negative Renice value.
    • 0.7%sy: Percentage of CPU time consumed by the kernel
    • Span style= "Font-family:microsoft Yahei; font-size:14px ">0.0%ni: Percentage of processes that have changed priority CPU consumption
    • 99.3%id: Percentage of idle CPU time
    • 0.0%wa: Percentage of CPU time waiting for I/O
    • 0.0%hi:cpu Hard Interrupt Time percentage
    • 0.0%si:cpu Soft Interrupt Time percentage
    • Note: Here the data is the average of all CPUs, if you want to see the processing of each CPU, press 1, fold, press 1 again;
  • line fourth
    • men: Memory meaning
    • 8175320kk total: Amount of physical memory
    • Span style= "Font-family:microsoft Yahei; Font-size:14px ">8058868k used: The amount of physical memory used
    • 116452k Free: Idle amount of physical memory
    • 283084k buffers: The amount of physical memory used as the kernel cache
  • Line Five
    • Swap: Swap space
    • 6881272K total: Swap area totals
    • 4010444K used: Amount of swap area used
    • 2870828k Free: Amount of idle swap area
    • 4336992k cached: Total buffer swap Area
  • Process information
    • And here's the process information:
    • PID: ID of the process
    • USER: Process Owner
    • PR: The priority level of the process, the smaller the higher the priority is executed
    • Ninice: Value
    • VIRT: Virtual memory consumed by the process
    • RES: The physical memory occupied by the process
    • SHR: Shared memory used by the process
    • S: The state of the process. s for hibernation, R for running, Z for Zombie, n for the process priority value is negative
    • %CPU: Process Consuming CPU utilization
    • %MEM: The percentage of physical memory and total memory used by the process
    • Time+: The total CPU time that is consumed after the process is started, which is the cumulative value of the CPU usage time.
    • Command: Process start name
1. Top command Interactive operation instruction

The following is a list of some common top command action directives

  • Q: Exit the top command
  • <space>: Refresh Now
  • S: Set Refresh time interval
  • C: Show command full mode
  • T:: Show or hide process and CPU status information
  • M: Show or hide memory status information
  • L: Show or hide uptime information
  • F: Increase or decrease the process display flag
  • S: Cumulative mode, the CPU time occupied by the completed or exited subprocess is accumulated to the parent process's mite+
  • P: Ranked by%CPU usage rate
  • T: Rank by mite+
  • M: Ranked by%mem
  • U: Specify display user process
  • R: Modify Process Renice Value
  • Kkill: Process
  • I: Show only running processes
  • W: Save settings for top to file ^/.TOPRC, the next boot will automatically call the settings of the TOPRC file.
  • H: Help command.
  • Q: Exit

Note: It is emphasized that the most frequently used is P, T, M, because top is usually used, and we want to see which processes consume the most CPU resources and occupy the most memory; Note: "Shift + >" or "Shift + <" You can change the sequence of rows to the right or left if you only need to view memory: The free command is available. View only uptime information (first line), the uptime command is available;

2. ExampleExample 1: Multi-core CPU monitoring

[[email protected] ^]$ toptop-09:10:44 up Days, 16:51, 4 users, load Average:3. 4.40, 4.40tasks:1201 Total, running, 1189 sleeping, 0 stopped, 2 zombiecpu0:1.3%us, 2.3%sy, 0.0%ni, 96.   4%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stcpu1:1.3%us, 2.6%sy, 0.0%ni, 96.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%STCPU2 : 1.0%us, 2.0%sy, 0.0%ni, 92.5%id, 0.0%wa, 0.0%hi, 4.6%si, 0.0%stcpu3:3.9%us, 7.8%sy, 0.0%ni, 83.2%id, 0.0 %wa, 0.0%hi, 5.2%si, 0.0%stcpu4:4.2%us, 10.4%sy, 0.0%ni, 63.8%id, 0.0%wa, 0.0%hi, 21.5%si, 0.0%stcpu5:6.8%u S, 12.7%sy, 0.0%ni, 80.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%stcpu6:2.9%us, 7.2%sy, 0.0%ni, 85.3%id, 0.0%wa, 0% Hi, 4.6%si, 0.0%stcpu7:6.2%us, 13.0%sy, 0.0%ni, 75.3%id, 0.0%wa, 0.0%hi, 5.5%si, 0.0%stmem:32943888k total, 3 2834216k used, 109672k free, 642704k buffersswap:35651576k total, 5761928k used, 29889648k free, 16611500k cached


Example 2: Highlighting the current running process
In the top basic view, press the keyboard "B" (Turn on/off the highlight effect);

Example 3: Displaying the complete program command

Command: Top-c


 
[[email protected] ^]$ top-ctop-09:14:35 up Days, 16:55, 4 users, Load Ave rage:5.77, 5.01, 4.64tasks:1200 Total, 5 running, 1192 sleeping, 0 stopped, 3 zombiecpu (s): 4.4%us, 6.0%sy, 0.0 %ni, 83.8%id, 0.2%wa, 0.0%hi, 5.5%si, 0.0%stmem:32943888k total, 32842896k used, 100992k free, 591484k BUFFERSSW ap:35651576k Total, 5761808k used, 29889768k free, 16918824k cachedpid USER PR NI VIRT RES SHR S%cpu%MEM T  ime+ COMMAND2013 Apache 0 403m 88m 5304 S 25.0 0.3 6:37.44/usr/sbin/httpd18335 pubtest 22 0 65576 996   728 r 7.8 0.0 0:00.24 netstat-naltp16499 rdtfare 0 13672 2080 824 R 2.6 0.0 0:00.38 top-c29684 rdtfare 0 1164m 837m 14m S 2.3 2.6 148:47.54/autodata data1.txt12976 pubtest 0 238m 9000 1932 s 1.6 0.0 439: 28.44 tscagent-s toev_p 

Example 4: Displaying the specified process information

<span style= "Font-family:microsoft yahei;font-size:14px;" > Command: Top-p pidid</span>

/opt/app/tdv1/config#top-p 17265top-09:17:34 up 455 days, 17:55,  2 users,  load average:3.76, 4.56, 4.46tasks:< C2/>1 Total,   0 running,   1 sleeping,   0 stopped,   0 zombiecpu (s):  7.8%us,  1.9%sy,  0.0%ni, 89.2%id,  0.0%wa,  0.1%hi,  1.0%si,  0.0%stmem:   8175452k Total,  8103988k used,    71464k free,   268716k buffersswap:  6881272k Total,  4275424k used,  2605848k free,  6338184k Cachedpid USER      PR  NI  VIRT  RES  SHR S%cpu%MEM    time+  COMMAND17265 tdv1      15   0 56504  828  632 S  0.0  0.0 195:53.25 redis-server

When you specify multiple process information, you need to replace the carriage return with other tools (-P supports pid,pid,pid syntax)

Command: top-p pgrep multi_process | TR "\ n" "," | Sed ' s/,$//'

/opt/app/tdv1$top-p ' Pgrep java | TR "\\n" "," |  Sed ' s/,$//' top-14:05:31 up,  2:43,  9 users,  load average:0.29, 0.34, 0.22Tasks:   3 Total,   0 Running,   3 sleeping,   0 stopped,   0 zombiecpu (s):  5.9%us,  8.2%sy,  0.0%ni, 86.0%id,  0.0 %wa,  0.0%hi,  0.0%si,  0.0%stmem:  66082088k Total, 29512860k used, 36569228k free,   756352k buffersswap:32767992k Total,  1019900k used, 31748092k free, 15710284k cached  PID USER      PR  NI  VIRT  RES  SHR s%cpu%MEM    time+  COMMAND                                          27855 rdtfare   0 4454m 1.3g 5300 s  0.7  2.0 338:31.37 Java 2034 Jenkins   0 18.3g 5.2g 5284 S  0.3  8.2  56:02.38 java    

12156 rdtfare 0 4196m 1.2g 12m S 0.3 2.0 86:34.62 java
3. More powerful toolsHtop

Htop is an interactive process browser under Linux that can be used to replace the top command under Linux.

Htop is more user-friendly than the traditional Linux top. It allows users to interact interactively, support color themes, scroll through the list of processes horizontally or vertically, and support mouse actions.

Compared to top, Htop has the following advantages:

    • You can scroll through the list of processes horizontally or vertically to see all the processes and the complete command line.
    • On startup, it's faster than top.
    • Process number is not required to kill the process.
    • Htop supports mouse operation.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Task Manager under Top Linux

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.