码迷,mamicode.com
首页 > 系统相关 > 详细

linux上的常用进程与内存优化

时间:2016-02-22 11:47:22      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

进程

  ps命令

    f 以树状结构显示

    u 显示详细信息

    a 显示所有进程

    -A 显示所有进程

    -u 用户名 是显示该用户下的进程

    -l 更多进程详细信息

    例子1. 以树状结构显示root用户下进程的详细信息

$ps fu -u root

    显示结果如下

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
         cpu占比
            内存占比
                 虚拟内存
                     驻留内存  root
2615 0.0 0.0 28180 248 ? S 09:07 0:00 /usr/sbin/dnsmasq --conf-file=/var/ root 2545 0.0 0.0 28180 244 ? S 09:07 0:00 /usr/sbin/dnsmasq --conf-file=/var/ root 2484 0.0 0.0 28180 240 ? S 09:07 0:00 /usr/sbin/dnsmasq --conf-file=/var/ root 2 0.0 0.0 0 0 ? S 09:06 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 09:06 0:00 \_ [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S< 09:06 0:00 \_ [kworker/0:0H] root 7 0.2 0.0 0 0 ? S 09:06 0:13 \_ [rcu_sched] root 8 0.0 0.0 0 0 ? S 09:06 0:00 \_ [rcu_bh] root 9 0.3 0.0 0 0 ? S 09:06 0:15 \_ [rcuos/0] root 10 0.0 0.0 0 0 ? S 09:06 0:00 \_ [rcuob/0] root 11 0.0 0.0 0 0 ? S 09:06 0:00 \_ [migration/0] root 12 0.0 0.0 0 0 ? S 09:06 0:00 \_ [watchdog/0] root 13 0.0 0.0 0 0 ? S 09:06 0:00 \_ [watchdog/1] root 14 0.0 0.0 0 0 ? S 09:06 0:00 \_ [migration/1] root 15 0.0 0.0 0 0 ? S 09:06 0:00 \_ [ksoftirqd/1] root 17 0.0 0.0 0 0 ? S< 09:06 0:00 \_ [kworker/1:0H] root 18 0.0 0.0 0 0 ? S 09:06 0:03 \_ [rcuos/1] root 19 0.0 0.0 0 0 ? S 09:06 0:00 \_ [rcuob/1] root 20 0.0 0.0 0 0 ? S 09:06 0:00 \_ [watchdog/2] root 21 0.0 0.0 0 0 ? S 09:06 0:00 \_ [migration/2] root 22 0.0 0.0 0 0 ? S 09:06 0:00 \_ [ksoftirqd/2] root 24 0.0 0.0 0 0 ? S< 09:06 0:00 \_ [kworker/2:0H] root 25 0.0 0.0 0 0 ? S 09:06 0:02 \_ [rcuos/2] root 26 0.0 0.0 0 0 ? S 09:06 0:00 \_ [rcuob/2] root 27 0.0 0.0 0 0 ? S 09:06 0:00 \_ [watchdog/3] root 28 0.0 0.0 0 0 ? S 09:06 0:00 \_ [migration/3] root 29 0.0 0.0 0 0 ? S 09:06 0:00 \_ [ksoftirqd/3]

      例子2:显示所有用户的详细信息

$ps aux

      显示效果如下

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  34304  4772 ?        Ss   09:06   0:01 /sbin/init
root         2  0.0  0.0      0     0 ?        S    09:06   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    09:06   0:00 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S<   09:06   0:00 [kworker/0:0H]
root         7  0.2  0.0      0     0 ?        S    09:06   0:15 [rcu_sched]
root         8  0.0  0.0      0     0 ?        S    09:06   0:00 [rcu_bh]
root         9  0.3  0.0      0     0 ?        S    09:06   0:17 [rcuos/0]
root        10  0.0  0.0      0     0 ?        S    09:06   0:00 [rcuob/0]
root        11  0.0  0.0      0     0 ?        S    09:06   0:00 [migration/0]
root        12  0.0  0.0      0     0 ?        S    09:06   0:00 [watchdog/0]
root        13  0.0  0.0      0     0 ?        S    09:06   0:00 [watchdog/1]
root        14  0.0  0.0      0     0 ?        S    09:06   0:00 [migration/1]
root        15  0.0  0.0      0     0 ?        S    09:06   0:00 [ksoftirqd/1]
root        17  0.0  0.0      0     0 ?        S<   09:06   0:00 [kworker/1:0H]
root        18  0.0  0.0      0     0 ?        S    09:06   0:03 [rcuos/1]
root        19  0.0  0.0      0     0 ?        S    09:06   0:00 [rcuob/1]

      例子3:显示,更多详细信息 -l

$ps -l

      显示效果如下:f

F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
标志   
状态(r运行,s睡眠,t终止,z僵尸) 
    用户 进程号 父进程
             cpu使用
               优先权
                 优先级修正
                    地址
                       使用内存
                         等待的进程资源
                             终端      运行时间 运行指令 
0 S 1000 6311 6303 0 80 0 - 7840 wait pts/0 00:00:00 bash 0 R 1000 6720 6311 0 80 0 - 4537 - pts/0 00:00:00 ps

      例子4:查找所需要的信息

   top命令

  /proc目录下查询

linux上的常用进程与内存优化

标签:

原文地址:http://www.cnblogs.com/yasmi/p/5206503.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!