LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-02-2009, 02:32 PM   #1
peter360
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Rep: Reputation: 0
how to see long command line of a running process


I have a process whose command line is longer than 4096 characters. When I tried ps wwwp <pid>, I see the command line is truncated at 4096 characters. cat /proc/<pid>/cmdline gave me the same result. Is there a way for me to see the entire command line? I assume 4096 is a default value which I can set somewhere.

Here is my system:

Linux dev1-28 2.6.18-92.1.13.el5.028stab059.6 #1 SMP Fri Nov 14 16:01:01 MSK 2008 x86_64 x86_64 x86_64 GNU/Linux

I am running Centos 5. Thanks.
 
Old 10-02-2009, 03:17 PM   #2
cpuobsessed
Member
 
Registered: Jan 2006
Distribution: Fedora, Ubuntu, Slackware
Posts: 56

Rep: Reputation: 15
Have you tried to pipe it into a file?
 
Old 10-02-2009, 06:18 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
To see full command options, I've always used:
  • $ ps auxww (bsd style); or
  • $ ps -ef

But... I don't think I've ever had a command + options exceeding 4096 bytes.

If that is not working out, you might review the "-o format" option in the ps(1) manpages. Perhaps a bit of tinkering and you'll get it to display. (Either that or there's a hardcoded limitation in place; I'm not sure.)
 
Old 10-03-2009, 05:24 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Try
Code:
cat /proc/<PID>/cmdline
where PID is, er, the PID of interest.
 
Old 10-04-2009, 05:53 PM   #5
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by peter360 View Post
Is there a way for me to see the entire command line? I assume 4096 is a default value which I can set somewhere.
You might try (as root):

Code:
sysctl -a | grep 4096
and see if anything interesting turns up. I just tried that and didn't see anything that looked like it might apply to your concern. (But I did see three errors I didn't understand. ) Or ... it could be something that is compiled into the kernel that can't be changed at run time. As a last ditch effort (that is unlikely to succeed) you might take a look at parameters you can supply to the kernel at boot time.

Realize that I am just making wild guesses here. This is *way* above my pay grade!
 
Old 10-05-2009, 01:29 PM   #6
peter360
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
First of all, thanks for all the replies. And wow, I did not expect this to be a hard problem. I thought it was something well known, even expecting some RTFMs. Anyway, glad we are going to learn something new. Here are some additional information:

* I did try to pipe the output to a file, like ps wwwp pid > file. That did not help.
* I did try cat /proc/pid/cmdline, that gave me the same output as ps did. I mentioned this in my original post.
* Following suggestion from blackhole54, I did sysctl -a | grep 4096, and got
net.ipv4.udp_wmem_min = 4096
net.ipv4.udp_rmem_min = 4096
net.ipv4.tcp_dma_copybreak = 4096
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
kernel.pty.max = 4096
kernel.random.poolsize = 4096
kernel.shmmni = 4096

I don't think any of these are related to the problem.
* I don't have any boot time kernel parameters specified. My grub file says
kernel /vmlinuz-2.6.18-92.1.13.el5.028stab059.6 ro root=/dev/VolGroup00/LogVol00
BTW is there a way I can query the boot parameter used while the system is running?

Anyhow, I suspect this is compiled into the kernel. Just out of curiosity, I wonder if other people are also seeing this. I wrote a simple shell script that will run a command longer than 4096 chars. Can some of you try it on your computer and let me know if you see the same problem? Here is how to do it
1 save the following shell script and run it
#!/bin/sh

# build a string of 5000 chars
long_arg=''
for i in $(seq 1 500)
do
long_arg=${long_arg}0123456789
done

# issue a blocking command with the long arg
exec awk "/$long_arg/{print}"

2 the awk command should block. In a separate terminal, do ps auxwww | grep awk. Do you see the command truncated?

Thanks!
 
Old 10-05-2009, 01:50 PM   #7
peter360
LQ Newbie
 
Registered: Oct 2009
Posts: 3

Original Poster
Rep: Reputation: 0
A colleague of mine pointed me to the answer:
http://stackoverflow.com/questions/1...096-byte-limit
 
Old 10-05-2009, 04:41 PM   #8
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by peter360 View Post
... even expecting some RTFMs.
That is rather discouraged around here. Although I have, very politely, in a effect told a few people that. After telling them where the FM was and how to use it.

Quote:
BTW is there a way I can query the boot parameter used while the system is running?
Code:
cat /proc/cmdline
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
launch a long running process at startup doru Linux - Newbie 2 09-10-2008 02:03 AM
Can kernel kill long-running process? registering Linux - Kernel 5 07-20-2007 08:45 AM
Passing command line arguments through getopts and long options neville310 Programming 3 04-16-2007 06:38 AM
Konsole wraps up long command to the same line rsashok Red Hat 2 01-30-2007 07:41 PM
How can I see what process are running and how to I kill them? (command line). brynjarh Linux - Newbie 4 07-07-2004 03:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 04:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration