2010-09-29

FreeBSD - The ps command output is truncated from the terminal width

There are a few commands that can list current process activity, "top" & "ps" are the most common one in use. The command "top" give an interactive view of the list of process running currently. But the command "ps" gives a more friendly output for scripting or text parsing. It also gives a lot of parameters to filter the output. One of the common parameters that I've always use is "ps aux". It list all the current process running with headers and information. By the way, "ps" stands for process status.

Usually, the process status output is pass to "less", a pager for ease of reading. Often, the "COMMAND" column of "ps aux" output, is truncated at the end of the terminal width. This behavior prevents the full process name from displaying. One thing good about this is, the output are not wrap so it won't mess up the output display. But most of the time, we'll want to view the full output.

There are 2 things to try in order to get the full output. First, try telling the pager (in this case, "less") don't chop the long lines after the terminal width, using parameter "-S".
e.g.
ps aux | less -S

If this doesn't work, then most likely is the process status ("ps aux") output is truncated before passing to "less". Tell "ps" not to truncate the output by :
ps auxww | less -S

The "w" parameter tells "ps" to use 132 column to display the output. But if more then one "w" parameters is specified, then use as many as possible to display the full output.

Experiment with the combination of "less" & "ps" to understand find out more.

Adios !!!

No comments: