61

Is there a way to generate a full process listing in solaris, without truncated lines? I've tried the ps command, with the following arguments:

  -f                  Generates a full listing. (See below for
                      significance  of columns in a full list-
                      ing.)
  -l                  Generates a long listing. (See below.)

So, those both seem to do what I want, however, further down in the ps man page, I find this:

 
 args                    The command with all its arguments as  a
                         string.  The implementation may truncate
                         this value to the  field  width;  it  is
                         implementation-dependent   whether   any
                         further   truncation   occurs.   It   is
                         unspecified     whether    the    string
                         represented is a version of the argument
                         list  as  it  was  passed to the command
                         when it started, or is a version of  the
                         arguments as they may have been modified
                         by the application. Applications  cannot
                         depend  on  being  able  to modify their
                         argument list and having that  modifica-
                         tion  be  reflected in the output of ps.
                         The Solaris  implementation  limits  the
                         string  to  80  bytes; the string is the
                         version of the argument list as  it  was
                         passed to the command when it started.

Which basically says the output is going to be truncated and there is nothing I can do about it. So, I'm coming here. Surely other people have run into this problem and maybe even have a way around it. I'm guessing ps can't do it and so I need to use other tools to do this. Is that accurate?

2
  • Are you talking about the ps command? If so then please update the question so that it's clearer.
    – phunehehe
    Commented Nov 12, 2010 at 17:31
  • Yeah, sorry... my initial tinkering was with the ps command, I've made the question clearer.
    – gabe.
    Commented Nov 13, 2010 at 0:42

5 Answers 5

68

you could try

pargs <PID>

this gives you a list of all arguments

or else use an other ps. If run as root (or any user with enough privileges for that matter)

/usr/ucb/ps auxww

will give you all arguments. Its part of SUNWscpu, "Source Compatibility, (Usr)"

3
  • pargs shows the in-process copy of the command line arguments (and optionally the environment). Good to know, thanks! Commented Nov 11, 2010 at 20:12
  • 1
    this whole /usr/ucb directory is new to me... I like it!
    – gabe.
    Commented Nov 16, 2010 at 20:39
  • 4
    On Solaris 11, if you use options without a dash (like "/usr/bin/ps auxwww") they will be treated as UCB style options, and the output will show extra long lines, even when you are NOT running as root. This is not well publicized. See also: superuser.com/questions/148271/ps-command-in-solaris Commented Nov 3, 2012 at 4:22
14

The kernel is not required to keep track of command line arguments. When a program is started through the execve call, the kernel must copy the arguments into the process memory (so that they will be available as argv in a C program, for example). After that, the kernel can discard the memory used to store the initial command line arguments. The process is allowed to overwrite its copy of the arguments. So there may simply be no trace of the arguments.

Some unix variants do keep a copy of the arguments in some form. Solaris exposes some data in /proc/$pid. As of OpenSolaris 2009.06, the only trace of the arguments is in /proc/$pid/psinfo, where they are concatenated with spaces in between (so you can't distinguish between foo "one" "two" and foo "one two") and the resulting string is truncated to 80 bytes. This field in /proc/$pid/psinfo is what ps prints in the args column.

By the way, the -f and -l options control what fields are printed, not whether the fields are truncated to some width.

3
  • This was a good answer as well, very informative. The pargs command met my need better which is the only reason I selected that answer over this one.
    – gabe.
    Commented Nov 16, 2010 at 19:07
  • 7
    So, once again we sit here in year 2013 and still we truncate strings to 80 bytes because we only had 80-char terminals in the 1970s and "some" programs have yet to understand the fact that life has moved on. And we like it, we praise this as "compatibility"! We should be ashamed of ourselves...
    – Manjabes
    Commented Jan 3, 2013 at 14:31
  • 1
    @Manjabes haha! People who choose to keep using Solaris shouldn't complain about the system doing things in an old-skool way ;-) Solaris is intentionally slow to change, to be more backwards compatible with older programs which expect certain behaviour. If you want an OS with a longer ps listing and more fancy capabilities in the utility programs you could use Linux instead.
    – JohnGH
    Commented Nov 12, 2015 at 18:41
2

ps -e gives the list of all the processes running. Also there's this ps -elf.

2
  • 2
    Even using -l argument still truncates the command line info Commented Nov 27, 2017 at 13:47
  • 1
    Not an answer to the question. Commented Feb 1, 2018 at 22:41
1

prstat will give you the currently running processes along with their pids and the CPU utilization.

0

Depending which ps command you use, I use

ps -auxw
1
  • 1
    The version of ps on Solaris that uses auxw arguments does not require a leading '-' If you're not on Solaris then your answer is not relevant.
    – JohnGH
    Commented Nov 12, 2015 at 18:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .