当前位置: 技术问答>linux和unix
第一次提问 top -n 1 ???
来源: 互联网 发布时间:2016-08-03
本文导语: top - 14:21:07 up 17:28, 7 users, load average: 0.00, 0.00, 0.00 Tasks: 117 total, 1 running, 116 sleeping, 0 stopped, 0 zombie Cpu(s): 3.5%us, 1.5%sy, 0.0%ni, 94.8%id, 0.1%wa, 0.0%hi, 0.0%si, 0.0%st Mem: 517144k total...
top - 14:21:07 up 17:28, 7 users, load average: 0.00, 0.00, 0.00
Tasks: 117 total, 1 running, 116 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.5%us, 1.5%sy, 0.0%ni, 94.8%id, 0.1%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 517144k total, 504692k used, 12452k free, 153660k buffers
Swap: 0k total, 0k used, 0k free, 175156k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10300 root 20 0 2384 1056 800 R 2 0.2 0:00.01 top
1 root 20 0 2096 684 584 S 0 0.1 0:03.17 init
2 root 15 -5 0 0 0 S 0 0.0 0:00.00 kthreadd
3 root RT -5 0 0 0 S 0 0.0 0:00.10 migration/0
4 root 15 -5 0 0 0 S 0 0.0 0:00.02 ksoftirqd/0
5 root RT -5 0 0 0 S 0 0.0 0:00.07 migration/1
6 root 15 -5 0 0 0 S 0 0.0 0:00.01 ksoftirqd/1
7 root 15 -5 0 0 0 S 0 0.0 0:08.91 events/0
8 root 15 -5 0 0 0 S 0 0.0 0:07.78 events/1
9 root 15 -5 0 0 0 S 0 0.0 0:00.02 khelper
38 root 15 -5 0 0 0 S 0 0.0 0:00.41 kblockd/0
39 root 15 -5 0 0 0 S 0 0.0 0:00.06 kblockd/1
43 root 15 -5 0 0 0 S 0 0.0 0:00.00 kseriod
166 root 20 0 0 0 0 S 0 0.0 0:00.00 pdflush
167 root 20 0 0 0 0 S 0 0.0 0:04.80 pdflush
168 root 15 -5 0 0 0 S 0 0.0 0:00.01 kswapd0
169 root 15 -5 0 0 0 S 0 0.0 0:00.00 aio/0
用top -n 1 这个指令,Cpu(s): 3.5%us,维持在3以上,然而用top 刷新 其值维持在1左右
我是用system(cmd) 把上面的内容放到top.log文件中再读取Cpu(s): 3.5%us的信息
cmd的指令可以是 top -n 5 -b
Tasks: 117 total, 1 running, 116 sleeping, 0 stopped, 0 zombie
Cpu(s): 3.5%us, 1.5%sy, 0.0%ni, 94.8%id, 0.1%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 517144k total, 504692k used, 12452k free, 153660k buffers
Swap: 0k total, 0k used, 0k free, 175156k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10300 root 20 0 2384 1056 800 R 2 0.2 0:00.01 top
1 root 20 0 2096 684 584 S 0 0.1 0:03.17 init
2 root 15 -5 0 0 0 S 0 0.0 0:00.00 kthreadd
3 root RT -5 0 0 0 S 0 0.0 0:00.10 migration/0
4 root 15 -5 0 0 0 S 0 0.0 0:00.02 ksoftirqd/0
5 root RT -5 0 0 0 S 0 0.0 0:00.07 migration/1
6 root 15 -5 0 0 0 S 0 0.0 0:00.01 ksoftirqd/1
7 root 15 -5 0 0 0 S 0 0.0 0:08.91 events/0
8 root 15 -5 0 0 0 S 0 0.0 0:07.78 events/1
9 root 15 -5 0 0 0 S 0 0.0 0:00.02 khelper
38 root 15 -5 0 0 0 S 0 0.0 0:00.41 kblockd/0
39 root 15 -5 0 0 0 S 0 0.0 0:00.06 kblockd/1
43 root 15 -5 0 0 0 S 0 0.0 0:00.00 kseriod
166 root 20 0 0 0 0 S 0 0.0 0:00.00 pdflush
167 root 20 0 0 0 0 S 0 0.0 0:04.80 pdflush
168 root 15 -5 0 0 0 S 0 0.0 0:00.01 kswapd0
169 root 15 -5 0 0 0 S 0 0.0 0:00.00 aio/0
用top -n 1 这个指令,Cpu(s): 3.5%us,维持在3以上,然而用top 刷新 其值维持在1左右
我是用system(cmd) 把上面的内容放到top.log文件中再读取Cpu(s): 3.5%us的信息
cmd的指令可以是 top -n 5 -b