• Linux Top查看指定进程的CPU状态


    查看top帮助信息

    不管linux还是unix,大多数命令都是支持man命令来查看帮助信息的。
    语法是下面这样,进入到交互界面后,用法类似vi,然后按「q」可以退出,输入「?」再输入关键字,可以查询相关关键字:

    man top
    

    帮助信息回显:

    
    TOP(1)                                                                                                                       User Commands                                                                                                                       TOP(1)
    
    NAME
           top - display Linux processes
    
    SYNOPSIS
           top -hv|-bcHiOSs -d secs -n max -u|U user -p pid -o fld -w [cols]
    ·····
    
    ·····
           -p  :Monitor-PIDs mode as:  -pN1 -pN2 ...  or  -pN1,N2,N3 ...
                Monitor only processes with specified process IDs.  This option can be given up to 20 times, or you can provide a comma delimited list with up to 20 pids.  Co-mingling both approaches is permitted.
    
                A pid value of zero will be treated as the process id of the top program itself once it is running.
    
                This is a command-line option only and should you wish to return to normal operation, it is not necessary to quit and restart top  --  just issue any of these interactive commands: '=', 'u' or 'U'.
    
                The 'p', 'u' and 'U' command-line options are mutually exclusive.
    

    执行命令

    找到帮忙信息之后,在「top」后面接上参数 「-p」就可以,还可以接多个这样的参数。下面是实例。

    top -p222 -p235
    

    结果预览

    top - 10:59:27 up 8 days, 23:04, 33 users,  load average: 19.29, 18.88, 15.68
    Tasks:   2 total,   0 running,   2 sleeping,   0 stopped,   0 zombie
    %Cpu(s): 28.0 us,  2.2 sy,  0.0 ni, 66.1 id,  3.5 wa,  0.0 hi,  0.1 si,  0.0 st
    KiB Mem:  13192180+total, 12092056+used, 11001252 free, 58405476 buffers
    KiB Swap: 13410816+total,    75264 used, 13403289+free. 34504364 cached Mem
    
      PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                                                                                  
      222 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/42:0H                                                                                                                                                                                            
      235 root      20   0       0      0      0 S   0.0  0.0   0:01.74 ksoftirqd/45
    
    

    小结

    遇到不会的Linux命令,不要慌、莫着急,用「man」查看帮助信息,帮忙信息太多,可以用用「/」或者「?」加上关键字可以搜索,可以说非常方便。还有一点就是多实践操作。


    作者:叉叉敌
    博客:https://chasays.github.io/
    微信公众号:Chasays, 欢迎关注一起吹牛逼,也可以加个人微信号「xxd_0225」互吹。
    本博客大多为学习笔记或读书笔记,本文如对您有帮助,还请多推荐下此文,如有错误欢迎指正,相互学习,共同进步。

  • 相关阅读:
    云原生生态周报 Vol. 16 | CNCF 归档 rkt,容器运行时“上古”之战老兵凋零
    Knative 基本功能深入剖析:Knative Eventing 之 Sequence 介绍
    基于 K8s 做应用发布的工具那么多, 阿里为啥选择灰姑娘般的 Tekton ?
    Serverless 的喧哗与骚动(一)附Serverless行业发展回顾
    239. Sliding Window Maximum
    237. Delete Node in a Linked List
    146. LRU Cache
    140. Word Break II
    165. Compare Version Numbers
    258. Add Digits
  • 原文地址:https://www.cnblogs.com/ievjai/p/14382721.html
Copyright © 2020-2023  润新知