我需要使用显示与终端相关的所有进程的命令。ps -a 看起来不错,只是没有打印用户名。该命令打印:
Run Code Online (Sandbox Code Playgroud)PID TTY TIME CMD 26969 pts/34 0:00 man 27636 pts/2 0:00 awk 25215 pts/35 0:00 bash
我希望它与此类似:
Run Code Online (Sandbox Code Playgroud)PID TTY TIME CMD USER 26969 pts/34 0:00 man name 27636 pts/2 0:00 awk name 25215 pts/35 0:00 bash name
列顺序并不重要
Jua*_*doy 11
使用:
ps a -o pid,tty,etime,cmd,user
Run Code Online (Sandbox Code Playgroud)
来自ps手册:
简单的工艺选择
Run Code Online (Sandbox Code Playgroud)a ... An alternate description is that this option causes ps to list all processes with a terminal (tty), or to list all processes与 x 选项一起使用时。
标准格式说明符
Run Code Online (Sandbox Code Playgroud)Here are the different keywords that may be used to control the output format (e.g. with option -o) or to sort the selected processes使用 GNU 风格的 --sort 选项。
Run Code Online (Sandbox Code Playgroud)For example: ps -eo pid,user,args --sort user