System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

 
SOLVED
Go to solution
vvsha
Frequent Advisor

CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

If I do, ps -ef, it shows the complete path of the command. However, if i pipe and grep, then, it shows the CMD field upto 32 characters only. I would like to change it as if it shows for ps -ef. Help highly appreciated.
10 REPLIES
Stuart Browne
Honored Contributor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

'ps -ef' will only show the shortened version of a cmdline.

Using 'ps -elf' will show the long version of the cmdline.

In either case, if outputing to the TTY, they'll be limited to COLUMNS width. When running in a pipe however, they shouldn't be limited, thus you should get more in a pipe.

i.e.: COLUMNS=132

ps -elf -> copy/paste 'clamav-milter' line:

clamav 18961 1 0 Apr13 ? 00:00:27 /usr/sbin/clamav-milter --quiet --external --dont-wait --force-scan --server=localho

ps -ef | grep clamav-milter -> output:

clamav 18961 1 0 Apr13 ? 00:00:27 /usr/sbin/clamav-milter --quiet --external --dont-wait --force-scan --server=localhost --pidfile=/var/run/clamav/clamav-milter.pid local:/var/run/clamav/clamav-milter.sock
One long-haired git at your service...
vvsha
Frequent Advisor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

Hi Stuart,

Actually If I do the
#ps -ef| grep
output shows only 32 characters in CMD column.

#ps -ef is giving correct output

But once I use pipe and grep its not

I have checked the same in other linux box, But it working there.
Hemmetter
Esteemed Contributor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

hi wsha


from ps(1):
-w Wide output. Use this option twice for unlimited width.

thus:

$ ps -wwef | grep ProcessName


rgds
HGH
vvsha
Frequent Advisor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

Hi,

If I do the
#ps -ef| grep
output shows only 32 characters in CMD column.
I have checked the same in other linux box, But it working there.

I want to do replicate the same settings .

Help highly appreciated.
Stuart Browne
Honored Contributor
Solution

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

Ok, what is 'COLUMNS' set to (echo $COLUMNS) ?

What does 'stty -a' say?

Try this as well:

env COLUMNS= ps -ef | grep <..>

Also try it again using 'ps -elf' instead of just '-ef'.
One long-haired git at your service...
vvsha
Frequent Advisor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

# echo $COLUMNS
125

But it is same in both the machine.
Stuart Browne
Honored Contributor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

'stty -a' output?

Also, what version of 'ps' on both machines (ps -V) ?
One long-haired git at your service...
vvsha
Frequent Advisor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

# ps -V
procps version 2.0.13
(Here it is working)


# ps -V
procps version 2.0.7
(Here not)
Stuart Browne
Honored Contributor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

.. is updating it out of the question ? ..
One long-haired git at your service...
vvsha
Frequent Advisor

Re: CMD field of ps -ef | grep <ProcessName> resricted to some 32 Characters only

Thanks.....