'time'命令的问题

时间:2011-07-29 09:07:58

标签: time exit status

我试图通过使用'/ usr / bin / time -p ./a.out'来计算应用程序的执行时间。这是返回'命令退出非零状态1',但它给我时间信息。我怎样才能摆脱这个错误。我知道这个错误代码与'time'命令有关。

2 个答案:

答案 0 :(得分:3)

来自time的手册页:

  

如果COMMAND以非零状态退出,则时间显示警告消息   和退出状态。

答案 1 :(得分:1)

只需使用“--quiet”选项,$ man / usr / bin / time:

--quiet: 
              Do not report the status of the program even if it is different from zero.