100 次迭代的 Bash shell 脚本和记录时间

标签 bash

如何使用 bash shell 脚本运行 100 次迭代?我想知道执行一个命令需要多长时间(开始和结束时间)。我想跟踪当前正在运行的迭代。我想记录每次迭代。我有一个自动化脚本需要运行并记录它。

for i in 1 2 3
do
    command1
done

但我想知道完成一次迭代需要多长时间 - 并将信息也写入日志文件!

最佳答案

您也可以在迭代中使用 seq:

for i in `seq 1 100`; do ... done

关于100 次迭代的 Bash shell 脚本和记录时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3723818/

相关文章:

linux - bash 删除旧文件

linux - 如何让 bash 将 undefined variable 视为错误?

linux - bash for循环中的迭代顺序是否得到保证?

bash - 在 Bash 中的文件夹中的所有文件名中出现一个字符串

bash - 将 grep 存储在变量中并在 bash 中执行 sed

bash - 在服务器上调用 R 以从主机上的 R session 中提取数据?

bash - 运行 Git 命令时无法读取 ' '

bash - 提取json字段内容失败

git 脚本 : How to list all git branches containing a commit

linux + 将 sh 脚本转换为 bash + bash 是否支持以前的 sh 脚本