zoukankan      html  css  js  c++  java
  • linux查看进程与线程数

    1. 查看进程:ps -ef 或 ps -aux

    得到进程的pid:
    如:
    ps -ef | grep process_name | grep -v "grep" | awk '{print $2}'

    2.根据进程号进行查询:

    # pstree -p 进程号

    # top -Hp 进程号

    3.根据进程名字进行查询:

    # pstree -p `ps -e | grep server | awk '{print $1}'`

    # pstree -p `ps -e | grep server | awk '{print $1}'` | wc -l

    4.查看线程数

    需要得到线程的PID

    查看进程的所有线程
    # ps mp 6648 -o THREAD,tid
    USER     %CPU PRI SCNT WCHAN  USER SYSTEM   TID
    root      0.0   -    - -         -      -     -
    root      0.0  24    - -         -      -  6648
    root      0.0  21    - -         -      -  6650
    root      1.0  24    - -         -      - 14214
    root      0.0  23    - futex_    -      - 14216
    root      0.0  22    - 184466    -      - 15374
    root      0.0  23    - 184466    -      - 15376
    root      0.0  23    - 184466    -      - 15378
    root      0.0  23    - 184466    -      - 15380
    root      0.0  23    - 184466    -      - 15392
    root      0.0  23    - 184466    -      - 15394
    root      0.0  23    - 184466    -      - 15398
    
    
    查看所有子进程:
    # pstree -p 6648
    agent_executor(6648)─┬─tar(15601)───gzip(15607)
                         ├─{agent_executor}(6650)
                         ├─{agent_executor}(14214)
                         ├─{agent_executor}(14216)
                         ├─{agent_executor}(15374)
                         ├─{agent_executor}(15376)
                         ├─{agent_executor}(15378)
                         ├─{agent_executor}(15380)
                         ├─{agent_executor}(15392)
                         ├─{agent_executor}(15394)
                         └─{agent_executor}(15398)

    5. 进程启动时间(运行多长时间)

    ps -eo lstart 启动时间

    ps -eo etime   运行多长时间.

    ps -eo pid,lstart,etime | grep 5176

    ========================================ps aux 或 lax 输出的解释=========================
    2ps aux 或 lax 输出的解释
    au(x) 输出格式 : 
    USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    
    USER: 进程所有者
    PID: 进程ID
    %CPU: 占用的 CPU 使用率
    %MEM: 占用的内存使用率
    VSZ: 占用的虚拟内存大小
    RSS: 占用的内存大小
    TTY: 终端的次要装置号码 (minor device number of tty)
    STAT: 进程状态:
    START: 启动进程的时间; 
    TIME: 进程消耗CPU的时间;
    COMMAND:命令的名称和参数;
  • 相关阅读:
    【原】使用Spring自带的JdbcTemplate。
    【原】MyBatis执行DDL:create table,drop table等等
    【转】java获取当前路径的几种方法
    【原】Java程序调用远程Shell脚本
    [转载] 使用Kettle进行数据迁移(ETL)
    appium原理
    python之global关键字的用法
    python之selenium定位(xpath)
    android 稳定性monkey测试
    python之selenium随记(几种等待的用法)
  • 原文地址:https://www.cnblogs.com/hubing/p/4935354.html
Copyright © 2011-2022 走看看