当前位置: 首页 > Linux学院 > 新手入门 > 系统基础 > linux中如何将top的结果输出到文件中保存

linux中如何将top的结果输出到文件中保存

2013-07-01 10:53 来源:风信网 作者:末信 人气指数: 我要评论

我们在使用top命令的时候,为了便于检查日志文件,往往需要将top的信息输出到一个文件中,进行保存,这样就能清楚的知道进程的使用情况啦!命令如下:

#top -d 2 -n 3 -b > test.txt

可以把top的结果每隔2秒,打印3次,这样后面页的进程也能够看见了

示例:

[root@localhost /]# top -d 2 -n 3 -b > test.txt
 

  1. top - 09:49:43 up  2:10,  1 user,  load average: 0.00, 0.00, 0.00  
  2. Tasks: 301 total,   1 running, 300 sleeping,   0 stopped,   0 zombie  
  3. Cpu(s):  0.0%us,  0.1%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st  
  4. Mem:   1938716k total,   682776k used,  1255940k free,    59192k buffers  
  5. Swap:  4194296k total,        0k used,  4194296k free,   257768k cached  
  6.  
  7.   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                  
  8.  3599 root      20   0  2832 1120  776 R  1.8  0.1   0:00.08 top                                                                      
  9.     1 root      20   0  2900 1444 1224 S  0.0  0.1   0:01.82 init                                                                     
  10.     2 root      20   0     0    0    0 S  0.0  0.0   0:00.01 kthreadd                                                                 
  11.     3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                              
  12.     4 root      20   0     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0                                                              
  13.     5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                              
  14.     6 root      RT   0     0    0    0 S  0.0  0.0   0:00.10 watchdog/0                                                               
  15.     7 root      RT   0     0    0    0 S  0.0  0.0   0:00.01 migration/1                                                              
  16.     8 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/1                                                              
  17.     9 root      20   0     0    0    0 S  0.0  0.0   0:00.02 ksoftirqd/1                                                              
  18.    10 root      RT   0     0    0    0 S  0.0  0.0   0:00.08 watchdog/1                                                               
  19.    11 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/2                                                              
  20.    12 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/2                                                              
  21.    13 root      20   0     0    0    0 S  0.0  0.0   0:00.01 ksoftirqd/2                                                              
  22.    14 root      RT   0     0    0    0 S  0.0  0.0   0:01.01 watchdog/2                                                               
  23.    15 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/3                                                              
  24.    16 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/3                                                              
  25.    17 root      20   0     0    0    0 S  0.0  0.0   0:00.01 ksoftirqd/3                                                              
  26.    18 root      RT   0     0    0    0 S  0.0  0.0   0:00.07 watchdog/3                                                               
  27.    19 root      20   0     0    0    0 S  0.0  0.0   0:00.39 events/0                                                                 
  28.    20 root      20   0     0    0    0 S  0.0  0.0   0:00.99 events/1                                                                 
  29.    21 root      20   0     0    0    0 S  0.0  0.0   0:00.35 events/2                                                                 
  30.    22 root      20   0     0    0    0 S  0.0  0.0   0:00.26 events/3                                                                 
  31.    23 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup                                                                   
  32.    24 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper                                                                  
  33.    25 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns                                                                    
  34.    26 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr                                                                
  35.    27 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm                                                                       
  36.    28 root      20   0     0    0    0 S  0.0  0.0   0:00.04 sync_supers                                                              
  37.    29 root      20   0     0    0    0 S  0.0  0.0   0:00.04 bdi-default                                                              
  38.    30 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0                                                            
  39.    31 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/1                                                            
  40.    32 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/2                                                            
  41.    33 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/3                                                            
  42.    34 root      20   0     0    0    0 S  0.0  0.0   0:00.21 kblockd/0                                                                
  43.    35 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kblockd/1                                                                
  44.    36 root      20   0     0    0    0 S  0.0  0.0   0:00.01 kblockd/2                                                                
  45.    37 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kblockd/3                                                                
  46.    38 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid                                                                   
  47.    39 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify                                                             
  48.    40 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug                                                            
  49.    41 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata/0                                                                    
  50.    42 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata/1                                                                    
  51.    43 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata/2                                                                    
  52.    44 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata/3                                                                    
  53.    45 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata_aux                                                                  
  54.    46 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksuspend_usbd                                                            
  55.    47 root      20   0     0    0    0 S  0.0  0.0   0:00.01 khubd                                                                    
  56.    48 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kseriod                                                                  
  57.    49 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md/0                                                                     
  58.    50 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md/1                                                                     
  59.    51 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md/2                                                                     
  60.    52 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md/3                                                                     
  61.    53 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md_misc/0                                                                
  62.    54 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md_misc/1                                                                
  63.    55 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md_misc/2                                                                
  64.    56 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md_misc/3                                                                
  65.    57 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khungtaskd                                                               
  66.    58 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kswapd0                                                                  
  67.    59 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd                                                                     
  68.    60 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/0                                                                    
  69.    61 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/1                                                                    
  70.    62 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/2                                                                    
  71.    63 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/3                                                                    
  72.    64 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/0                                                                 
  73.    65 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/1                                                                 
  74.    66 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/2                                                                 
  75.    67 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/3                                                                 
  76.    72 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthrotld/0                                                               
  77.    73 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthrotld/1                                                               
  78.    74 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthrotld/2                                                               
  79.    75 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthrotld/3                                                               
  80.    76 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pciehpd                                                                  
  81.    78 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kpsmoused                                                                
  82.    79 root      20   0     0    0    0 S  0.0  0.0   0:00.00 usbhid_resumer                                                           
  83.   109 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kstriped                                                                 
  84.   206 root      20   0     0    0    0 S  0.0  0.0   0:00.02 scsi_eh_0                                                                
  85.   217 root      20   0     0    0    0 S  0.0  0.0   0:00.03 scsi_eh_1                                                                
  86.   269 root      20   0     0    0    0 S  0.0  0.0   0:00.28 mpt_poll_0                                                               
  87.   270 root      20   0     0    0    0 S  0.0  0.0   0:00.00 mpt/0                                                                    
  88.   271 root      20   0     0    0    0 S  0.0  0.0   0:00.00 scsi_eh_2                                                                
  89.   362 root      20   0     0    0    0 S  0.0  0.0   0:00.20 jbd2/sda2-8                                                              
  90.   363 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  91.   364 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  92.   365 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  93.   366 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  94.   457 root      20   0     0    0    0 S  0.0  0.0   0:00.15 flush-8:0                                                                
  95.   461 root      16  -4  3132 1360  364 S  0.0  0.1   0:00.13 udevd                                                                    
  96.   669 root      20   0     0    0    0 S  0.0  0.0   0:00.35 vmmemctl                                                                 
  97.  1070 root      18  -2  3524 2028  600 S  0.0  0.1   0:00.03 udevd                                                                    
  98.  1117 root      20   0     0    0    0 S  0.0  0.0   0:00.00 jbd2/sda1-8                                                              
  99.  1118 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  100.  1119 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  101.  1120 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  102.  1121 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  103.  1122 root      20   0     0    0    0 S  0.0  0.0   0:00.00 jbd2/sda5-8                                                              
  104.  1123 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  105.  1124 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  106.  1125 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  107.  1126 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ext4-dio-unwrit                                                          
  108.  1171 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kauditd                                                                  
  109.  1401 root      20   0  2056  512  440 S  0.0  0.0   0:00.00 portreserve                                                              
  110.  1408 root      20   0 37000 1556 1056 S  0.0  0.1   0:00.07 rsyslogd                                                                 
  111.  1451 rpc       20   0  2576  824  628 S  0.0  0.0   0:00.25 rpcbind                                                                  
  112.  1466 dbus      20   0 13512 1436  904 S  0.0  0.1   0:00.27 dbus-daemon                                                              
  113.  1477 root      20   0 21236 4132 3556 S  0.0  0.2   0:00.12 NetworkManager                                                           
  114.  1481 root      20   0  4592 2176 1836 S  0.0  0.1   0:00.04 modem-manager                                                            
  115.  1498 rpcuser   20   0  2840 1284  876 S  0.0  0.1   0:00.01 rpc.statd                                                                
  116.  1505 root      20   0  7308  640  436 S  0.0  0.0   0:00.00 wpa_supplicant   
  117. ...... 
为您推荐: Linux 文件 TOP
大家感兴趣的内容
小伙伴最爱的新闻
小伙伴还关注了以下信息
小伙伴关注的焦点

小伙伴都在关注的热门词

新服 缤纷活动 航海世纪 芈月传 暗黑道具 萌乐网 苹果发布会 最新谍照 三国令 剑雨江湖 怎样修炼战骑 页游 怎样修炼伙伴 木甲世界 仙侠道2 推黑科技 页游模式 武圣试炼场 街机玩法 蓝月传奇 个人BOSS玩法 哥们网 九阴绝学 仗剑出鞘 全新模式 范伟打天下 全新元神玩法 七大神兵简介 新手攻略 跑腿任务 门派五行 城战礼包 页游界 泥石流 傅园慧 经典网页游戏 耐玩 盘点 玉石攻略 提升角色 大黑 实装属性 神兵攻略 问鼎莽荒 莽荒纪 手持神兵 土豪梦 万世 开学清单 财富赚不停 天书世界 大黑游戏 资源战场 ppwan 天问 激战 全国大战 雄霸一方 新增宠物技能 绝对小能手 花千骨 三尾章鱼 风色轨迹 双枪手 弑之神 缤纷好礼 惊喜六重连 帮会 中秋福利 自制月饼 九阴真经 玩家 五周年纪念 纪念银币 名动三界 新服资料片 画江山 勇战妖魔 邪恶势力 上古降魔 老司机玩法 坐骑揭秘 黑科技 竞技场攻略 铁血皇城 披风玩法 书剑恩仇录 装备强化攻略 野外BOSS玩法 全网曝光 赤壁传说 半回合制国 ACT 奇珍商城 热血战歌 传奇宝藏抽奖 打开方式 门徒 门徒获取玩法 三大萌宠简介