| 用途 | 按需选列输出进程信息 |
|---|---|
| 语法 | ps -eo 列1,列2,... [--sort=列] |
| 常用列 | pid ppid stat etime etimes lstart cmd %cpu %mem nlwp |
常用示例
常用示例
ps -eo pid,ppid,stat,etime,cmd --sort=-etime | head
ps -eo pid,lstart,cmd | grep -i java # 启动时间
ps -eo pid,nlwp,cmd --sort=-nlwp | head # 线程数排行
ps -p 1234 -o pid,ppid,stat,etime,lstart,cmd # 单进程详情
ps -eo stat | sort | uniq -c | sort -rn | head # 进程状态分布stat 首位含义:R 运行、S 睡眠、D 不可中断、Z 僵尸、T 停止;带 + 是前台,带 l 是多线程。