Search code examples
bashshellfile-iotop-command

Bash script output of a top command


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?


Solution

  • 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