Bash top 命令的脚本输出
Bash script output of a top command
当我执行命令时
top -c -b -n | grep XXX > TEST
在 Red Hat Linux 命令行上,top
命令中的所有路径和其余内容都被导出到 TEST
文件中(在一行中它写了更多比 100 columns/character,例如)。
但是,当我在脚本中添加相同的命令并通过 crontab
运行 时,输出每次都只有 81 column/character.
如何获取 cron
脚本中的全角信息?
解释在 man top
的第 1 部分:
-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
和 LINES
由您的终端在启动时和调整其大小时设置 window.
您可以尝试以下方法:
COLUMNS=1000 top -c -b -n 1 | grep XXX > TEST
这将确保 COLUMNS 环境变量值设置为较大的值。
礼貌:ServerFault
当我执行命令时
top -c -b -n | grep XXX > TEST
在 Red Hat Linux 命令行上,top
命令中的所有路径和其余内容都被导出到 TEST
文件中(在一行中它写了更多比 100 columns/character,例如)。
但是,当我在脚本中添加相同的命令并通过 crontab
运行 时,输出每次都只有 81 column/character.
如何获取 cron
脚本中的全角信息?
解释在 man top
的第 1 部分:
-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
和 LINES
由您的终端在启动时和调整其大小时设置 window.
您可以尝试以下方法:
COLUMNS=1000 top -c -b -n 1 | grep XXX > TEST
这将确保 COLUMNS 环境变量值设置为较大的值。
礼貌:ServerFault