Bash:计算脚本运行需要多长时间

标签 bash

有没有办法让 bash 脚本打印运行时间?

一些相当简单的东西,比如:

#!/bin/bash
something to start time
command to be run
something to calculate runtime and print result

最佳答案

有标准工具time .

脚本:

#!/bin/bash

echo start
sleep 2
echo end

用法:

$ time ./so.sh       
start
end
./so.sh  0.00s user 0.01s system 0% cpu 2.007 total

关于Bash:计算脚本运行需要多长时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37695776/

相关文章:

bash - shell :选择唯一的平面文件行

Bash:从用户输入读取字符串后,字符串的错误 "interpretation"

linux - 如何将linux命令日志捕获到文件中?

bash - 如何在不特别命名文件的情况下将文件向上移动一个目录并删除旧目录?

linux - 使用 bash 中的给定前缀将批量文件复制到另一个目的地

linux - 如何将特定文件复制到特定文件夹 linux bash

java - 如何在 linux 系统启动脚本中启用 java 路径?

bash - 在复杂的 bash if 语句中使用 grep 的返回码作为 true false

bash脚本: Loop through a directory

linux - 如何在特定编号的目录中查找具有特定模式的文件? Linux