老李分享:《Linux Shell脚本攻略》 要点(八)上

老李分享:《Linux Shell脚本攻略》 要点(八)

1、打印进程

[root@localhost program_test]# ps -e | head
  PID TTY          TIME CMD
    1 ?        00:00:03 init
    2 ?        00:00:00 kthreadd
    3 ?        00:00:00 migration/0
    4 ?        00:00:00 ksoftirqd/0
    5 ?        00:00:00 migration/0
    6 ?        00:00:00 watchdog/0
    7 ?        00:00:00 events/0
    8 ?        00:00:00 cgroup
    9 ?        00:00:00 khelper

 

2、top 占用CPU最多的进程列表

[root@localhost program_test]# top

top - 23:45:17 up  1:12,  5 users,  load average: 0.00, 0.00, 0.00
Tasks: 153 total,   1 running, 143 sleeping,   9 stopped,   0 zombie
Cpu(s):  0.3%us,  0.3%sy,  0.0%ni, 99.0%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
Mem:   1030528k total,   377184k used,   653344k free,    32588k buffers
Swap:  2064376k total,        0k used,  2064376k free,   170968k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                  
4429 root      20   0  2704 1140  880 R  0.7  0.1   0:00.12 top                                                                                                      
   21 root      20   0     0    0    0 S  0.3  0.0   0:01.63 ata_sff/0                                                                                                
2462 yy       20   0 73100  23m  18m S  0.3  2.3   0:12.11 vmtoolsd                                                                                                 
    1 root      20   0  2900 1436 1212 S  0.0  0.1   0:03.10 init      

 

3、列出占CPU最多的进程

[root@localhost program_test]# ps -eo comm,pcpu --sort -pcpu | head
COMMAND         %CPU
Xorg             0.5
vmtoolsd         0.2
vmtoolsd         0.2
init             0.0
kthreadd         0.0
migration/0      0.0
ksoftirqd/0      0.0
migration/0      0.0
watchdog/0       0.0


你可能感兴趣的:(软件测试开发)