Solved

How to print a non-truncated "argument" field for the command "ps"?

Posted on 2003-11-12
11
552 Views
Last Modified: 2013-12-27
I am using JRun on a Solaris platform, and when I us the "ps" command, I found that there are so many java threads running that even exhuasted the system's memory. I want to know what those threads are for. But the output of "ps" is something like below and that makes me unable to know what command and arguments started those threads:


# ps -ef | grep jrun
    root  4204     1  0   Nov 11 ?        0:00 /bin/sh ./jrun start default-app
    root  4501  4204  0   Nov 11 ?        0:21 /opt/jdk1.2.2/bin/../bin/sparc/native_threads/java -classpath=
    root 10654 10024  0 15:30:59 ?        1:12 /opt/jdk1.2.2/bin/../bin/sparc/native_threads/java -classpath=

The "command and arguments" field is truncated. I read the man page of ps and it didn't mentioned how to extend the field width. Anyone know how to do it?

And, in fact I am not sure whether a non-truncated "command and argument" field would give me enough information to know where in my Java program is giving birth to so many threads. I wonder if there is any other command I can use to investigate these threads? I understand that a Java debugger might help me more about this. But I am not the admin of this Solaris server and hence I can't install any extra tools to use.
0
Comment
Question by:wcleung9
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 38

Expert Comment

by:yuzh
ID: 9736966
You can  can use:

ps -e -o pid,ppid,arg

to do the job, "-o" specify" the output format, and what you what to print.

man ps
to learn more
0
 
LVL 38

Expert Comment

by:yuzh
ID: 9737023
Sorry abou the typo, it should be: (missing a "s")

ps -e -o pid,ppid,args
0
 
LVL 38

Expert Comment

by:yuzh
ID: 9737033
something must be wrong with my keyboad, missing a "t" for "about"
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 24

Accepted Solution

by:
shivsa earned 125 total points
ID: 9737204
u can use truss to see what is your program doin.

truss -p <pid of your java program>.

this will keep running your program and if program forks child and all it will keep track of those.
please do man truss for more info.
0
 
LVL 20

Expert Comment

by:tfewster
ID: 9740122
0
 

Author Comment

by:wcleung9
ID: 9822798
Sorry that I didn't make any replies for two weeks....

I tried `ps -e -o pid,ppid,args`. But it only specifies what columns are there in the output, and can't specifies the width of each column. The "command and argument" column is still truncated.

Then I tried `/usr/ucb/ps guww`. It can really print out the whole command. But it seems to be different from the normal `ps`...? I can't find the processes I was investigating.....

Finally, I used `truss` and solved my problem. Thx alot shivsa !! But I don't know whether I should accept you answer. Because your answer , though thankfully solved my problem, seems not relevant to the Question Title....I am more than willing to give you the points, but.....I am not familiar with the rules here, should I accept the answer??
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9822807
We are here to help u with solution, if your problem is solved with my answer than u should accept my answer.
I gave u my answer thinking that it might be obstructing your work, and i gave u quick solution. u may put a comment at the end saying what u feel and close it.

thanks,
shiv
-------------------------------
You can close the question by following this guidelines:

http://www.experts-exchange.com/help.jsp#hs5

0
 
LVL 38

Expert Comment

by:yuzh
ID: 9824907
"Finally, I used `truss` and solved my problem. Thx alot shivsa !! But I don't know whether I should accept you answer. Because your answer , though thankfully solved my problem, seems not relevant to the Question Title....I am more than willing to give you the points, but.....I am not familiar with the rules here, should I accept the answer??"

Good to hear "truss" solved your problem. You should award the points to shivsa.

It is very often we gave commet seems not relevant to the Question Title, but
can solve the problem. (It depands on the natural of the problem, not the question
title).

Cheers!
0
 

Author Comment

by:wcleung9
ID: 9847675
Understood. Thx everybody ~~
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9864611
You can close the question by following this guidelines:

http://www.experts-exchange.com/help.jsp#hs5
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9864918
sorry for my last comment, i am logging after 2 days and could not see that u already closed the issue.

thanks,
Shiv
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question