PS 명령의 전체 출력보기
ps -aux
퍼티를 사용하여 연결된 Linux 서버에서 명령을 실행할 때 현재 창 너비에 맞지 않는 프로세스는 거의 없습니다. 대안이 있습니까?
-업데이트-
다운 그레이드에 대해 죄송합니다. 다른 사람들도 그 대답이 유용하지 않다고 생각하여 다운 그레이드했습니다.
요청한 정보는 다음과 같습니다.
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
그것은 당신이 같은 호출기를 사용하고있는 것으로 보인다 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
출력 단자에 때만 화면 폭을 사용한다.
auxww
플래그를 사용하면 터미널 창과 셸 스크립트 모두에서 출력 할 전체 경로를 볼 수 있습니다.
darragh@darraghserver ~ $uname -a
SunOS darraghserver 5.10 Generic_142901-13 i86pc i386 i86pc
darragh@darraghserver ~ $which ps
/usr/bin/ps<br>
darragh@darraghserver ~ $/usr/ucb/ps auxww | grep ps
darragh 13680 0.0 0.0 3872 3152 pts/1 O 14:39:32 0:00 /usr/ucb/ps -auxww
darragh 13681 0.0 0.0 1420 852 pts/1 S 14:39:32 0:00 grep ps
ps aux
모든 사용자가 실행 한 모든 프로세스를 나열합니다. 자세한 내용 man ps
을 참조하십시오. ww
플래그는 무제한 폭을 설정합니다.
-w Wide output. Use this option twice for unlimited width.
w Wide output. Use this option twice for unlimited width.
다음 블로그에서 답을 찾았습니다.
http://www.snowfrog.net/2010/06/10/solaris-ps-output-truncated-at-80-columns/
간단하고 완벽한 :
ps -efww
줄을 자르지 않습니다
자동 줄 바꿈 고양이에 던져
ps aux | cat
몇 초만 지나면 w
디스플레이 너비가 무시됩니다.
If you are specifying the output format manually you also need to make sure the args
option is last in the list of output fields, otherwise it will be truncated.
ps -A -o args,pid,lstart
gives
/usr/lib/postgresql/9.5/bin 29900 Thu May 11 10:41:59 2017
postgres: checkpointer proc 29902 Thu May 11 10:41:59 2017
postgres: writer process 29903 Thu May 11 10:41:59 2017
postgres: wal writer proces 29904 Thu May 11 10:41:59 2017
postgres: autovacuum launch 29905 Thu May 11 10:41:59 2017
postgres: stats collector p 29906 Thu May 11 10:41:59 2017
[kworker/2:0] 30188 Fri May 12 09:20:17 2017
/usr/lib/upower/upowerd 30651 Mon May 8 09:57:58 2017
/usr/sbin/apache2 -k start 31288 Fri May 12 07:35:01 2017
/usr/sbin/apache2 -k start 31289 Fri May 12 07:35:01 2017
/sbin/rpc.statd --no-notify 31635 Mon May 8 09:49:12 2017
/sbin/rpcbind -f -w 31637 Mon May 8 09:49:12 2017
[nfsiod] 31645 Mon May 8 09:49:12 2017
[kworker/1:0] 31801 Fri May 12 09:49:15 2017
[kworker/u16:0] 32658 Fri May 12 11:00:51 2017
but ps -A -o pid,lstart,args
gets you the full command line:
29900 Thu May 11 10:41:59 2017 /usr/lib/postgresql/9.5/bin/postgres -D /tmp/4493-d849-dc76-9215 -p 38103
29902 Thu May 11 10:41:59 2017 postgres: checkpointer process
29903 Thu May 11 10:41:59 2017 postgres: writer process
29904 Thu May 11 10:41:59 2017 postgres: wal writer process
29905 Thu May 11 10:41:59 2017 postgres: autovacuum launcher process
29906 Thu May 11 10:41:59 2017 postgres: stats collector process
30188 Fri May 12 09:20:17 2017 [kworker/2:0]
30651 Mon May 8 09:57:58 2017 /usr/lib/upower/upowerd
31288 Fri May 12 07:35:01 2017 /usr/sbin/apache2 -k start
31289 Fri May 12 07:35:01 2017 /usr/sbin/apache2 -k start
31635 Mon May 8 09:49:12 2017 /sbin/rpc.statd --no-notify
31637 Mon May 8 09:49:12 2017 /sbin/rpcbind -f -w
31645 Mon May 8 09:49:12 2017 [nfsiod]
31801 Fri May 12 09:49:15 2017 [kworker/1:0]
32658 Fri May 12 11:00:51 2017 [kworker/u16:0]
you can set output format,eg to see only the command and the process id.
ps -eo pid,args
see the man page of ps for more output format. alternatively, you can use the -w
or --width n
options.
If all else fails, here's another workaround, (just to see your long cmds)
awk '{ split(FILENAME,f,"/") ; printf "%s: %s\n", f[3],$0 }' /proc/[0-9]*/cmdline
Sorry to be late to the party but just found this solution to the problem.
The lines are truncated because ps insists on using the value of $COLUMNS, even if the output is not the screen at that moment. Which is a bug, IMHO. But easy to work around, just make ps think you have a superwide screen, i.e. set COLUMNS high for the duration of the ps command. An example:
$ ps -edalf # truncates lines to screen width
$ COLUMNS=1000 ps -edalf # wraps lines regardless of screen width
I hope this is still useful to someone. All the other ideas seemed much too complicated :)
If none of the solutions above work, the output of ps
isn't your problem. Maybe you need to set putty to wrap long lines?
Otherwise, we need more information.
If you grep
the command that you are looking for with a pipe from ps aux, it will wrap the text automatically. I used a lot of the other answers on here, but sometimes if you are looking for something specific, it is nice to just use grep
and you know that it will wrap lines.
For instance ps aux | grep ffmpeg
.
I found this answer which is what nailed it for me as none of the above answers worked
https://unix.stackexchange.com/questions/91561/ps-full-command-is-too-long
Basically, the kernel is limiting my cmd line.
참고URL : https://stackoverflow.com/questions/2159860/viewing-full-output-of-ps-command
'programing tip' 카테고리의 다른 글
Log4net이 로그 파일을 쓰지 않습니다 (0) | 2020.06.10 |
---|---|
List <>에서 마지막 요소를 어떻게 찾을 수 있습니까? (0) | 2020.06.10 |
UNIX 소켓 파일에 대한 mysqld_safe 디렉토리 '/ var / run / mysqld'가 존재하지 않습니다. (0) | 2020.06.10 |
안드로이드에서 원형 ProgressBar를 만드는 방법은 무엇입니까? (0) | 2020.06.10 |
MySQL : 테이블을 만들 수 없음 (errno : 150) (0) | 2020.06.10 |