用 top 输出一次性的 CPU 快照
输出一份按 CPU 排序的单次报告,而不是持续刷新的实时画面。
运行 top -l 1 -o cpu,采样一次并按当前 CPU 占用从高到低列出进程。
01命令
命令
$ top -l 1 -o cpu02作用说明
top 默认会持续刷新终端,不利于脚本和截图。-l 1 让它进入日志模式:只采样一次、打印报告后退出。再加上 -o cpu,进程表就会按 CPU 占用排序,最繁忙的进程排在最前面。
03风险
!注意: 第一次 -l 采样的 CPU 数值往往偏低甚至为 0,因为 macOS 的 top 需要两次采样才能计算增量;可以运行 top -l 2 取第二次的结果,或用 -stats pid,command,cpu 精简列。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- top — display and update sorted information about processes (macOS)依据: The page documents -l for logging mode (one shot) and notes that -u is an alias equivalent to "-o cpu -O time", confirming -o cpu sorts by CPU usage.
- top(1) man page依据: The synopsis shows -l <samples> ("Use logging mode and display <samples> samples") and -o <key> for the sort-order column, with cpu as a valid key.
最后验证: 2026-09-19 · 分类: 系统与设置