0

I have a local and a remote machine. I would like to let a R script run on my remote machine. Since it is computationally expensive, it will take quite some time.

How can I execute a command/script on the remote server, such that it continues the computation even after detaching?

My operating system on the remote server is Ubuntu 16. I use a ssh connection.

vranjes
  • 47
  • 6
  • I won't mark duplicate, but [this SO question](https://stackoverflow.com/questions/18306362/run-r-script-from-command-line) seems to be what you want here. Please search SO before posting a question. – Tim Biegeleisen Sep 14 '18 at 06:15
  • Thank you for your input Tim. But the question is how to let it run even after detaching. – vranjes Sep 14 '18 at 06:35
  • Then see the answer below. You may use a Windows scheduled task. This doesn't really have much to do with R per se. – Tim Biegeleisen Sep 14 '18 at 06:37
  • Please add some more system details - operating system, method of remote connection etc etc. – Spacedman Sep 14 '18 at 07:05
  • What's the operating system on your remote machine? A solution with Linux is to use `screen` and then start your script as usual with `Rscript file.R`. You can change back to the terminal window with `ctrl+a+d`, see list of screens with `screen -ls` and get back to your running script with `screen -r `. – Paul Sep 14 '18 at 07:11
  • If you run the script from the command line with `RScript` you can use `disown` and/or `nohup` or commands like that to let it run after logging off – divibisan Sep 14 '18 at 18:09
  • Possible duplicate of [Getting ssh to execute a command in the background on target machine](https://stackoverflow.com/questions/29142/getting-ssh-to-execute-a-command-in-the-background-on-target-machine) – divibisan Sep 14 '18 at 18:09

1 Answers1

1

I think you can create a batch file in the remote desktop machine and if you want it to run on fixed time you can use Task scheduler feature in Windows to schedule the batch file.

Hunaidkhan
  • 1,411
  • 2
  • 11
  • 21