我在远程服务器上有R
个文件test.R
.它只包含以下内容:
Sys.sleep(5)
在我的本地计算机中,我有我的local.R
文件:
library(ssh)
host<-"root@someip"
keyfile<-"mykeyfile.osh"
passwd<-"mypassword"
ssh_session <- ssh::ssh_connect(host,keyfile,passwd)
print(Sys.time())
a<-ssh::ssh_exec_wait(ssh_session,
command = 'nohup R CMD BATCH test.R &')
print(Sys.time())
ssh::ssh_disconnect(ssh_session)
当我执行local.R
时,我得到以下输出:
[1] "2023-09-16 17:41:52.707577 CEST"
[1] "2023-09-16 17:41:58.132833 CEST"
如果你观察,这两个时间之间的差异超过5秒.我期待的是第二版不要等到完成test.R
的执行.我的最终目标是让它在一款shiny
应用程序上运行.
编辑.我也用了command = 'nohup Rscript test.R &'
,但结果还是差不多的.
有什么主意吗? 谢谢!