Reputation: 409
My project requires "Top" out to be redirect in a file.
I am running couple of application. When I tun top on telnet I am getting full path of one of my application. It looks like as follows
2079 1952 root R 12296 2% 0% -s=1 -PrjPath="/usr/local/Myproject/Application" -stgMode=1
But when I use following command to redirect the out put to file it gets truncated.
Command:
tope -b -n1
Out put:
2079 1952 root R 12296 2% 0% -s=1 -PrjPath="/usr/local/Myproject/Appl
Can any one tell me why it is truncated ? How to get it full.
Following is my environment. Embedded linux kernel v2.6.29. busyboxy v1.10.4
"top" command is part of busybox.
Thanks in Advance Bhargav Vyas
Upvotes: 2
Views: 4099
Reputation: 10682
I had a truncating issue even after using the
-c :Command-line/Program-name toggle
option in batch mode. So I had to specify the output width with -w, like
top -b -n 1 -c -w 200
for example.
From the man page:
-w :Output-width-override as: -w [ number ]
In Batch mode, when used without an argument top will format output using the COLUMNS= and LINES= environment variables, if set. Otherwise, width will be fixed at the maximum 512 columns. With an argument, output width can be decreased or increased (up to 512) but the number of rows is considered unlimited.
In normal display mode, when used without an argument top will attempt to format output using the COLUMNS= and LINES= environment variables, if set. With an argument, output width can only be decreased, not increased. Whether using environment variables or an argument with -w, when not in Batch mode actual terminal dimensions can never be exceeded.
Note: Without the use of this command-line option, output width is always based on the terminal at which top was invoked whether or not in Batch mode.
Upvotes: 3
Reputation: 55
Use can use "-c" parameter to display the complete command, and you need to make sure the screen width is wide enough to display it. Ex:
COLUMNS=512 top -b -n1 -c
One side effect would be, the complete path of the command will be displayed. This cannot be avoided. You should also consider using ps, which is much more customizable.
To display only the command names:
ps -eo pcpu,pid,user,comm | sort -k 1 -r
To display with arguments and path:
ps -eo pcpu,pid,user,args | sort -k 1 -r
and so on.
Upvotes: 5