获取 nohup R 程序完成的时间

Get the time when nohup R program finishes

我想知道程序完成的时间。但它总是显示相同的时间。这是我的 shell 脚本。它始终显示 START TIMEEND TIME 相同。我该如何解决?

START=$(date +"%r") 
nohup Rscript program_1.R >program_1.Rout & wait & echo START TIME = $START\n END TIME = " `date +"%r"`";

您仅将 R 脚本发送到后台,date 立即执行。

而不是

date +%r; sleep 5 & date +%r

date +%r; (sleep 5; date +%r) &