Bash Shell脚本可进行100次迭代并消耗日志时间 [英] Bash shell script for 100 iterations and log time taken

查看:164
本文介绍了Bash Shell脚本可进行100次迭代并消耗日志时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How do I run 100 iterations using a bash shell script? I want to know how long it will take to execute one command (start and end time). I want to keep track which iteration is currently running. I want to log each iteration. I have one automated script I need to run and log it.

for i in 1 2 3
do
    command1
done

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

But I want to know how long it takes to complete one iteration - and write the information to a log file too!

推荐答案

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

You may use seq in iteration as well:

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

这篇关于Bash Shell脚本可进行100次迭代并消耗日志时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆