Run the Linux Command to view the cpu usage of processes.

Source: Internet
Author: User

View cpu usage information of processes in memory. For Linux Command-TOP, we use the top command to view CPU usage. Top does not produce output, and the screen content remains unchanged. It refreshes the screen to display new information. Therefore, if you only execute top and keep the screen open, the screen will always display the latest information. The command to exit top is q, or press Ctrl-C. top-17:03:45 up 58 days, 1 user, load average: 0.00, 0.02, 0.00 Tasks: 172 total, 1 running, 171 sleeping, 0 stopped, 0 zombieCpu (s ): 0.2% us, 0.1% sy, 0.0% ni, 99.7% id, 0.0% wa, 0.0% hi, 0.0% siMem: 4037036 k total, 4007280 k used, 29756 k free, 93384 k buffersSwap: 8385888 k total, 71536 k used, 8314352 k free, 3068240 k cached pid user pr ni virt res shr s % CPU % mem time + COMMAND 27167 oracle 16 0 2011 m 490 m 483 m S 1 12.4. 93 oracle 27175 oracle 15 0 2011 m 517 m 510 m S 1 13.1. 78 oracle 5003 oracle 15 0 2021 m 33 m 29 m S 0 0.9. 10 oracle 1 root 16 0 4756 552 S 0 460. 31 init 2 root RT 0 0 0 S 0 0.0. 47 migration/0 ............................... the first line (top): top-17:03:45 up 58 days, 17:03:45, 1 user, load average: 0.00, 0.02, 0.00 "" indicates the current system Time; "58 days," indicates the current operating time after the system is started; "1 user" indicates the user currently logged on to the system, more specifically, the number of terminals that log on to a user-connections to multiple terminals of the system from the same user at the same time are considered as connections from multiple users to the system, the number of users here will also be the number of terminals; "load average" is the average value of the current system load, the following three values are the average number of processes one minute ago, five minutes ago, and 15 minutes ago. Generally, when this value exceeds the number of CPUs, the CPU will be hard to load the processes contained in the current system; the second line (Tasks): "172 total" indicates the total number of processes in the current system; "1 running" indicates the number of processes currently running; "171 sleeping" indicates the number of processes in the waiting state; "0 stoped" indicates the number of stopped system processes; "0 zombie" indicates the number of frozen processes; and the third line is Cpus): displays detailed information about CPU usage. If multiple CPUs exist, the screen displays one CPU message per line.. Row 4 (Mem): displays the available and used memory line 5 (Swap): indicates the same category as row 4 (Mem), but this shows the Swap). In general, Swap partitions (Swap) are frequently used and are considered to be caused by insufficient physical memory. Other display content displays processes in table format. The following is an explanation of the columns: the column describes the PID process's process ID. the USER's PRI process that runs the process has a priority. NI nice: the higher the value, the lower the task priority, the SIZE of the memory used by the process (code + Data + stack) RSS the physical memory used by the process SHARE the shared memory used by the process STAT the status of the process, display with code. Some major status codes include: R-running S-sleeping Z-lagging T-stopped. You will also see the second and third characters, which indicate: w-replaced process N-positive nice Value % CPU usage of the Process % MEM memory usage of the process TIME total CPU usage of the process if this is more processor System, this column specifies the cpu id of the running process on it. You can use the top internal COMMAND to control the display mode of the process. The internal command is as follows: s-change the screen update frequency l-close or enable the first line of top information in the first line t-close or enable the first part of the second line of Tasks and the third line of Cpus information m-close or enable the expression N of the first part of the fourth line Mem and the fifth line Swap information. In the order of PID size, the process list P is displayed. In the order of CPU usage, the Process List M is displayed. memory usage in the order of the size of the Process List h-show help n-set the number of processes displayed in the Process List q-exit top ----------------------------------------------- dynamic view a process memory usage 1, top command top -d 1-p pid [, pid...] // set it to delay 1 s. The default value is delay 3 s. If you want to Sort data by memory usage, you can shift + m (Sort by memory usage) static view of a process memory use 1, pmap command pmap pid 2, ps command ps aux | grep process_name 3, view the status File Name: php State in the/proc/process_id/folder: R (running) SleepAVG: 0% Tgid: 21574 Pid: 21574 PPid: 10005 TracerPid: 0 Uid: 1000 1000 1000 1000 Gid: 100 100 100 FDSize: 100 Groups: 16 256 VmPeak: 161740 kB VmSize: 161740 kB VmLck: 0 kB VmHWM: 107144 kB VmRSS: 107144 kB VmData: 106192 kB VmStk: 84 kB VmExe: 5588 kB VmLib: 7884 kB VmPTE: 268 kB Threads: 1 SigQ: 0/69632 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000001000 SigCgt: 00000001818040a7 CapInh: 0000000000000000 CapPrm: 0000000000000000 CapEff: 0000000000000000 seconds: Average seconds, 00000000,000 minutes F Mems_allowed: 1. Task virtual address space size VmSize the physical memory used by the application VmRSS

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.