与nohup一起狂欢


14

我想知道在nohup中运行某些东西需要花费多少时间。我知道这可行:

$ time sleep 2

real    0m2.001s
user    0m0.000s
sys     0m0.001s

但是,为什么它不能与nohup一起使用?

$ nohup time sleep 2 &
[1] 29456
$ nohup: ignoring input and appending output to 'nohup.out'
nohup: failed to run command 'time': No such file or directory

[1]+  Exit 127                nohup time sleep 2

Answers:


20

它不起作用,因为它time是一个shell关键字。有外部time二进制文件,但您似乎没有安装。这可能会起作用:

nohup bash -c 'time sleep 2'

对。我们将在“ nohup.out”中看到它仅花费了2秒钟以上。
— 格琳·杰克曼

谢谢。我安装了time rpm,但现在也可以使用。
— BartBiczBoży
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.