top

进程查看器,找到当前正在运行的CPU程序

语法

  top options

选项



  -b   以批处理模式运行; 不接受命令行输入。
       用于将输出发送到另一个命令或文件。
  -c   在显示中显示命令行而不仅仅是命令名
  -d delay
       指定刷新间隔时间
  -i   禁止显示空闲和僵尸进程
  -n num
       更新显示num次,然后退出。
  -p pid
       仅监视具有指定进程ID的进程。
  -q   刷新没有延迟.
       如果用户具有特权,则以最高优先级运行
  -s   安全模式。禁用一些(危险的)交互式命令
  -S   累积模式。打印每个进程的总CPU时间,
       包括死子过程。

交互式命令

space    立即更新显示
  A      按运行时长排序
  c      切换命令名或完整命令行显示
  f, F   添加要显示的字段或从显示中删除字段。
  h, ?   显示有关命令和安全模式和累积模式状态的帮助。
  k      为进程ID杀死和发送信号(默认是15)杀死它的rompt
  i      不显示空闲进程和僵尸进程
  l      切换负载平均和正常运行时间信息的显示
 ^L      屏幕重绘
  m      切换内存信息的显示
  M      根据驻留内存使用情况对任务进行排序。
  n, #   提示要显示的进程数量
         如果输入了0,则在屏幕上显示尽可能多的值(默认)
  N      按进程ID进行数字排序
  o, O   更改显示字段的顺序。
  P      按CPU使用率(默认)对任务进行排序。
  q      退出.
  r      将renice应用于进程。提示PID和renice值。安全模式下不显示
  s      更改刷新之间延迟。
         提示新的延迟时间,以秒为单位
  S      切换累积模式. (参见 -S option.)
  t      切换进程和CPU状态信息的显示。
  T      按时间/累计时间对任务进行排序。
  W      将当前设置写入~/.toprc。这是编写顶级配置文件的推荐方法。

Top 显示每个进程的CPU使用率(不是总服务器负载),与过去的某些点相比,它对于查看机器现在正在执行的工作量非常有用。

例子

要显示按CPU使用率排序的进程,每5秒更新一次:

 $ top -Ps5

top 命令实例:

linux命令:top -b -n 1 | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}' "count}' D: status "Total {print END } count++} {print; "D") == ($8 if else print; <=7) (NR '{if awk | 1 -n -b top top -b -n 1 | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}'rootopen.com
linux命令:top -b -n 1 | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}' "count}' D: status "Total {print END } count++} {print; "D") == ($8 if else print; <=7) (NR '{if awk | 1 -n -b top top -b -n 1 | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}'rootopen.com
2018-04-17 15:49:48

linux命令:top top toprootopen.com
linux命令:top top toprootopen.com
2018-02-23 15:53:48

linux命令:top -b -n 1 1 -n -b top top -b -n 1rootopen.com
linux命令:top -b -n 1 1 -n -b top top -b -n 1rootopen.com
2018-04-29 23:33:48

linux命令:top -bn 1 | awk '{if($1 ~ /^[0-9]+$/ && $9 > 97) {print $1;exit}}'|xargs kill kill $1;exit}}'|xargs {print 97) > $9 && /^[0-9]+$/ ~ '{if($1 awk | 1 -bn top top -bn 1 | awk '{if($1 ~ /^[0-9]+$/ && $9 > 97) {print $1;exit}}'|xargs killrootopen.com
linux命令:top -bn 1 | awk '{if($1 ~ /^[0-9]+$/ && $9 > 97) {print $1;exit}}'|xargs kill kill $1;exit}}'|xargs {print 97) > $9 && /^[0-9]+$/ ~ '{if($1 awk | 1 -bn top top -bn 1 | awk '{if($1 ~ /^[0-9]+$/ && $9 > 97) {print $1;exit}}'|xargs killrootopen.com
2018-05-19 09:31:48

linux命令:top -b -n 1 |grep httpd|wc -l -l httpd|wc |grep 1 -n -b top top -b -n 1 |grep httpd|wc -lrootopen.com
linux命令:top -b -n 1 |grep httpd|wc -l -l httpd|wc |grep 1 -n -b top top -b -n 1 |grep httpd|wc -lrootopen.com
2018-04-23 17:27:48

linux命令:top top toprootopen.com
linux命令:top top toprootopen.com
2018-01-17 17:50:48

linux命令:top -p `pidof apache2 | awk '{gsub(/[ ]/,",");print}'` ]/,",");print}'` '{gsub(/[ awk | apache2 `pidof -p top top -p `pidof apache2 | awk '{gsub(/[ ]/,",");print}'`rootopen.com
linux命令:top -p `pidof apache2 | awk '{gsub(/[ ]/,",");print}'` ]/,",");print}'` '{gsub(/[ awk | apache2 `pidof -p top top -p `pidof apache2 | awk '{gsub(/[ ]/,",");print}'`rootopen.com
2018-06-06 21:37:48

linux命令:top -p `pgrep pidgin` pidgin` `pgrep -p top top -p `pgrep pidgin`rootopen.com
linux命令:top -p `pgrep pidgin` pidgin` `pgrep -p top top -p `pgrep pidgin`rootopen.com
2018-01-11 03:08:48

linux命令:top -b -n 1 | sed 1,6d 1,6d sed | 1 -n -b top top -b -n 1 | sed 1,6drootopen.com
linux命令:top -b -n 1 | sed 1,6d 1,6d sed | 1 -n -b top top -b -n 1 | sed 1,6drootopen.com
2018-04-14 15:11:48

linux命令:top $(pgrep foo | sed 's|^|-p |g') |g') 's|^|-p sed | foo $(pgrep top top $(pgrep foo | sed 's|^|-p |g')rootopen.com
linux命令:top $(pgrep foo | sed 's|^|-p |g') |g') 's|^|-p sed | foo $(pgrep top top $(pgrep foo | sed 's|^|-p |g')rootopen.com
2018-02-10 22:46:48

linux命令:top '-p' $(pgrep -d ' -p ' foo) foo) ' -p ' -d $(pgrep '-p' top top '-p' $(pgrep -d ' -p ' foo)rootopen.com
linux命令:top '-p' $(pgrep -d ' -p ' foo) foo) ' -p ' -d $(pgrep '-p' top top '-p' $(pgrep -d ' -p ' foo)rootopen.com
2018-05-01 08:31:48

linux命令:top -p $(pgrep -d , foo) foo) , -d $(pgrep -p top top -p $(pgrep -d , foo)rootopen.com
linux命令:top -p $(pgrep -d , foo) foo) , -d $(pgrep -p top top -p $(pgrep -d , foo)rootopen.com
2018-02-02 13:27:48

linux命令:top -n2 -d 0.5 | grep ^Cpu | sed 's/[[:alpha:]%]*//g' | awk 'NR == 2 {printf("%.2f\n",100-$5)}' {printf("%.2f\n",100-$5)}' 2 == 'NR awk | 's/[[:alpha:]%]*//g' sed | ^Cpu grep | 0.5 -d -n2 top top -n2 -d 0.5 | grep ^Cpu | sed 's/[[:alpha:]%]*//g' | awk 'NR == 2 {printf("%.2f\n",100-$5)}'rootopen.com
linux命令:top -n2 -d 0.5 | grep ^Cpu | sed 's/[[:alpha:]%]*//g' | awk 'NR == 2 {printf("%.2f\n",100-$5)}' {printf("%.2f\n",100-$5)}' 2 == 'NR awk | 's/[[:alpha:]%]*//g' sed | ^Cpu grep | 0.5 -d -n2 top top -n2 -d 0.5 | grep ^Cpu | sed 's/[[:alpha:]%]*//g' | awk 'NR == 2 {printf("%.2f\n",100-$5)}'rootopen.com
2018-05-25 15:37:48

linux命令:top -bn2|awk -F, '/Cpu/{if (NR>4){print 100-gensub(/.([^ ]+).*/,"\\1","g",$4)}}' ]+).*/,"\\1","g",$4)}}' 100-gensub(/.([^ (NR>4){print '/Cpu/{if -F, -bn2|awk top top -bn2|awk -F, '/Cpu/{if (NR>4){print 100-gensub(/.([^ ]+).*/,"\\1","g",$4)}}'rootopen.com
linux命令:top -bn2|awk -F, '/Cpu/{if (NR>4){print 100-gensub(/.([^ ]+).*/,"\\1","g",$4)}}' ]+).*/,"\\1","g",$4)}}' 100-gensub(/.([^ (NR>4){print '/Cpu/{if -F, -bn2|awk top top -bn2|awk -F, '/Cpu/{if (NR>4){print 100-gensub(/.([^ ]+).*/,"\\1","g",$4)}}'rootopen.com
2018-05-30 09:16:48

Linux的Bash命令行(A-Z排序)