How to save the rails command from the Rails Console launched after closing the SSH client (PuTTy)

I connect to our Ubuntu server using PuTTy.

I want to reindex a specific model using Solr. I want to run the reindex command from the Rails console, i.e. Modelname.reindex (as this is faster than the rake task).

However, we are looking at a huge amount of data, and it is expected that this indexing will take several hours.

I want to run this task in the rails console and continue it even if I exit PuTTy. How to do it?

Linux: preventing the background process from stopping after closing the SSH client offers nohup, but I donโ€™t see if / how it can be used with the rails console.

+6
source share
3 answers

Use sudo apt-get install screen to install screen . Then run it with screen . Now you have a separate console window that you can detach with Ctrl + A , then D Closing putty will not end your screen segment. If you log back in at any later time, you can resume sessions using screen -r .

Summarizing:

 > sudo apt-get install screen > screen # pops up a new shell > rails c # run your reindex operation # press Ctrl + A, then D > exit # putty closes # reconnect using putty > screen -r # you should be back in your rails console 
+9
source

What you can do is use screen or tmux so that your session opens on the server.

If you simply type screen , a terminal multiplexer will be launched, which will support the session, even if you turn off the console.

Once you reconnect to the console, you can return the session with screen -dr

0
source

You should use something like tmux or a screen and disconnect from the session.

0
source

Source: https://habr.com/ru/post/918942/


All Articles