Reputation: 5
When I execute command
top -c -b -n | grep XXX > TEST
on Red Hat Linux command line, all the paths and the rest of the stuff from the top
command is exported into the TEST
file (in one line it wrote more than 100 columns/character, for example).
However, when I add the same command in a script and run it via crontab
, the output is every time only until the 81 column/character.
How can I get the full width information in the cron
script?
Upvotes: 0
Views: 2158
Reputation: 5861
You could try the following:
COLUMNS=1000 top -c -b -n 1 | grep XXX > TEST
This will ensure that COLUMNS environment variable value is set to a large value.
Courtesy: ServerFault
Upvotes: 0
Reputation: 58938
The explanation is in section 1 of man top
:
-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 termi‐
nal dimensions can never be exceeded.
Note: Without the use of this command-line option, out‐
put width is always based on the terminal at which top
was invoked whether or not in Batch mode.
COLUMNS
and LINES
are set by your terminal when you start it and when you resize its window.
Upvotes: 1