标签: time-command

为什么`time` 命令不适用于任何选项?

我尝试使用time带有-f选项的命令来格式化时间的输出,但出现以下错误:

-f: command not found
Run Code Online (Sandbox Code Playgroud)

然后我试图使用其他选项-a-o等我也得到了同样的错误。甚至time --version不起作用(--version: command not found)。

不要告诉我读那个人,因为我已经读过很多次了......所有这些选项都在那里指定。那么,问题可能出在哪里呢?

command-line bash time-command

79
推荐指数
3
解决办法
3万
查看次数

尝试为时间命令设置格式时找不到命令

我正在尝试获取运行命令所需的时间,并以特定格式输出:

time -f "%E" ls -l
Run Code Online (Sandbox Code Playgroud)

这类似于手册页(以及在线手册页)中的示例。但是,当我运行此命令时,我得到:

-f: command not found
Run Code Online (Sandbox Code Playgroud)

似乎 time 命令没有将 -f 作为参数读取,而是作为我尝试运行的命令。

如何以特定格式获取命令的执行时间?

command-line bash time-command

16
推荐指数
1
解决办法
5628
查看次数

如何在 bash 中自动计时命令?

tcsh,有变量time

   The time shell variable can be set to execute the time builtin command
   after the completion of any process that takes more than a given number
   of CPU seconds.
Run Code Online (Sandbox Code Playgroud)

我如何做到这一点bash

bash time-command

14
推荐指数
1
解决办法
2672
查看次数

为什么时间的输出格式取决于我如何称呼它

这可能是一个新手的问​​题,但我不明白这是如何配置的以及为什么time在这两种情况下命令的输出格式不同:

如果使用 via time,输出是三行基本信息

$ time sleep 1

real    0m1.003s
user    0m0.000s
sys     0m0.000s
Run Code Online (Sandbox Code Playgroud)

然后我可以检查使用的是哪个二进制文件

$ which time
/usr/bin/time
Run Code Online (Sandbox Code Playgroud)

并直接调用它以完全不同的格式获得输出,并提供更多信息

$ /usr/bin/time sleep 1
0.00user 0.00system 0:01.00elapsed 0%CPU (0avgtext+0avgdata 2000maxresident)k
0inputs+0outputs (0major+77minor)pagefaults 0swaps
Run Code Online (Sandbox Code Playgroud)

没有相关的别名 time

$ alias | grep time
$ 
Run Code Online (Sandbox Code Playgroud)

我在跑Ubuntu 16.04

command-line bash time-command

14
推荐指数
1
解决办法
906
查看次数

执行 /usr/bin/time 时没有那个文件或目录

我正在构建自己的android rom。为了构建它,我需要运行

mka -j8 bacon
Run Code Online (Sandbox Code Playgroud)

但是,我想测量构建它所花费的时间,所以我使用了

/usr/bin/time -f "User\t%U\nSys\t%S\nReal\t%E\nCPU\t%P" mka -j8 bacon
Run Code Online (Sandbox Code Playgroud)

这不会运行,因为它说

/usr/bin/time: cannot run mka: No such file or directory
Run Code Online (Sandbox Code Playgroud)

任何有关如何解决此问题的帮助,不胜感激!我正在运行 xubuntu。

编辑:

出于某种原因,使用 make 而不是 mka 确实有效,但是使用mka更好。

/usr/bin/time -f "User\t%U\nSys\t%S\nReal\t%E\nCPU\t%P" make -j8 bacon
Run Code Online (Sandbox Code Playgroud)

编辑 2: 来自cyanogenmod 网站

调用$ source build/envsetup.sh$ . build/envsetup.sh从您的 shell 运行构建目录中的 envsetup.sh 脚本。envsetup.sh 为构建环境添加了许多功能,下面列出了其中最重要的功能。

source build/evnsetup.sh是我在执行时间之前运行的命令。evnsetup.sh 添加的功能之一是mka,是否可以从time命令中调用它?

编辑 3:mka 类型的输出

$ type mka
mka is a function
mka () 
{ …
Run Code Online (Sandbox Code Playgroud)

command-line bash time-command

11
推荐指数
1
解决办法
1万
查看次数

自动在 gedit 中打印终端输出?

命令

time ./myprog 
Run Code Online (Sandbox Code Playgroud)

在屏幕上显示运行 myprog 所花费的时间。现在我想将此信息写入文本文件。

如何?

command-line bash time-command

4
推荐指数
2
解决办法
3077
查看次数

为什么运行 `time` 和 `/usr/bin/time` 给出不同的结果?

为什么运行time/usr/bin/time给出不同的结果?

/usr/bin/时间

thomas@tbdesktop:~$ /usr/bin/time -f "Elapsed time:%E" wc /etc/hosts
  9  25 224 /etc/hosts
Elapsed time:0:00.04
Run Code Online (Sandbox Code Playgroud)

时间

thomas@tbdesktop:~$ time -f "Elapsed time:%E" wc /etc/hosts
-f: command not found

real    0m0.079s
user    0m0.052s
sys 0m0.024s
Run Code Online (Sandbox Code Playgroud)

我的路径如下。据我所知,time路径中只有一个可执行文件。

thomas@tbdesktop:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
thomas@tbdesktop:~$ find / -name time 2> /dev/null
/sys/devices/pnp0/00:03/rtc/rtc0/time
/sys/module/printk/parameters/time
/var/lib/dkms/virtualbox/4.1.12/build/common/time
/var/lib/doc-base/documents/time
/usr/src/linux-headers-3.2.0-30/kernel/time
/usr/src/linux-headers-3.2.0-31-generic/include/config/sr/report/time
/usr/src/linux-headers-3.2.0-31-generic/include/config/generic/time
/usr/src/linux-headers-3.2.0-31-generic/kernel/time
/usr/src/virtualbox-4.1.12/common/time
/usr/src/linux-headers-3.2.0-29/kernel/time
/usr/src/linux-headers-3.2.0-30-generic/include/config/sr/report/time
/usr/src/linux-headers-3.2.0-30-generic/include/config/generic/time
/usr/src/linux-headers-3.2.0-30-generic/kernel/time
/usr/src/linux-headers-3.2.0-29-generic/include/config/sr/report/time
/usr/src/linux-headers-3.2.0-29-generic/include/config/generic/time
/usr/src/linux-headers-3.2.0-29-generic/kernel/time
/usr/src/linux-headers-3.2.0-31/kernel/time
/usr/bin/time
/usr/share/doc/time
/usr/share/doc-base/time
thomas@tbdesktop:~$ 
Run Code Online (Sandbox Code Playgroud)

command-line environment-variables time-command

4
推荐指数
1
解决办法
1644
查看次数