Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pause R and resume it later?

Tags:

r

I have a very big dataset with more than 100 millions of rows. I am running a loop on that dataset. The code has been running since two days ago and I forgot to add a counter to see how much time is left. I am working at a place that the desks are first come first serve so you cannot have a specific desk and at the end of each day, you have to logout the system. My problem is if I logout the system, I will loose the two days of work. Is there any way that I can pause R, logout my system, come back tomorrow morning and resume my work? I am working with UNIX. I appreciate if someone can help me with this.

Regards, Mahsa

like image 225
Mahsa Avatar asked Jan 08 '15 20:01

Mahsa


1 Answers

If you're on a unix system, you'll most likely have access to a program called "screen".

If it's available, you can open up a terminal, start screen, start R, then close the terminal while R is still running in the background.

Then at a later time, or the next day, you simply open up another terminal, and use screen to connect back into the previously created session.

the steps:

  1. in your terminal, start screen

    screen
    
  2. start R, and run your program

  3. Close your terminal, just click the x, don't ctrl-d.

...hours later

  1. open a new terminal, type

    screen -ls
    

    to get a list of currently running screen sessions

  2. reconnect to the session of your choosing

    screen -r 34234
    
like image 149
kith Avatar answered Oct 30 '22 16:10

kith