当我在我的linux服务器上运行ps -aux命令时,我使用putty连接到它,很少有进程太长而不能适应我当前的窗口宽度。还有别的选择吗?

——更新——

很抱歉我降级了,我觉得别人也不会觉得这个答案有用,所以我降级了。

这是你要的资料。

hadoop-user@hadoop-desk:~$ echo $TERM
xterm

hadoop-user@hadoop-desk:~$ stty -a
speed 38400 baud; rows 47; columns 158; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

hadoop-user@hadoop-desk:~$ echo $COLUMNS
158

当前回答

以上这些都不适用于带有busybox的docker容器。我用的是:

$ cat /proc/<PID>/cmdline | tr \\0 ' '

其他回答

如果您使用来自ps aux的管道grep正在查找的命令,它将自动换行文本。我在这里使用了很多其他答案,但有时如果您正在寻找一些特定的东西,只使用grep是很好的,您知道它会自动换行。

例如ps aux | grep ffmpeg。

传递给它几个ws将忽略显示宽度。

只要把它扔到cat上,它就会自动换行

ps aux | cat

很可能您正在使用一个寻呼机,如less或most,因为ps aux的输出比满屏的要长。如果是这样,以下选项将导致(或强制)长行换行,而不是被截断。

ps aux | less -+S

ps aux | most -w

如果使用下列命令之一,将不会换行,但可以使用方向键或其他移动键向左或向右滚动。

ps aux | less -S    # use arrow keys, or Esc-( and Esc-), or Alt-( and Alt-) 

ps aux | most       # use arrow keys, or < and > (Tab can also be used to scroll right)

对于more和pg,行总是被换行。

当ps aux在管道中使用时,w选项是不必要的,因为ps只在输出到终端时使用屏幕宽度。

您可以设置输出格式,例如只查看命令和进程id。

ps -eo pid,args

有关更多输出格式,请参阅ps的手册页。或者,您可以使用-w或——width n选项。

如果所有这些都失败了,这里有另一个解决方案,(只是为了看到你的长cmd)

awk '{ split(FILENAME,f,"/") ; printf "%s: %s\n", f[3],$0 }' /proc/[0-9]*/cmdline