bash時にnohupを使う

bash時にnohupを使う

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

ベストアンサー1

timeshellキーワードのため機能しません。外部バイナリがありますが、timeインストールしていないようです。これはうまくいくかもしれません:

nohup bash -c 'time sleep 2'

おすすめ記事