I connect to our Ubuntu production 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 seems to run quicker than the rake task.)
We are, however, looking at a vast volume of data and this indexing is expected to take a few hours.
I want to be able to start this task in the rails console and it should continue running even if I exit PuTTy. How to do this?
Linux: Prevent a background process from being stopped after closing SSH client suggests nohup, but I don't see if/how that can be used with the rails console.
Use sudo apt-get install screen
to install screen
. Then run it using screen
. Now you have a separate console window which can be detached using Ctrl + A
, then D
. Closing putty will not end your screen
-session. If you log back in at any later point, you may resume the sessions using screen -r
.
To summarize:
> 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With